dgs.models.metric.metric.NegativeSoftmaxEuclideanSquaredDistance.forward¶
- NegativeSoftmaxEuclideanSquaredDistance.forward(input1: torch.Tensor, input2: torch.Tensor) torch.Tensor [source]¶
First compute the squared Euclidean distance between the two inputs. The second dimension of the inputs has to match. Then compute the softmax of the negative distance along the second dimension.
- Parameters:
input1 – tensor of shape
[a x E]
input2 – tensor of shape
[b x E]
- Returns:
A tensor of shape
[a x b]
containing the similarity between the inputs as probability. By default, the softmax is computed along the last dimension, but you can change the behavior by changing the kwargs during initialization.