dgs.models.metric.metric.NegativeSoftmaxEuclideanDistance.forward¶
- NegativeSoftmaxEuclideanDistance.forward(input1: torch.Tensor, input2: torch.Tensor) torch.Tensor [source]¶
First compute the Euclidean distance between the two inputs, of which the second dimension 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.