torchtraining.metrics.distance¶
-
class
torchtraining.metrics.distance.Cosine(dim: int = 1, eps: float = 1e-08, reduction=<built-in method mean of type object>)[source]¶ Cosine distance between
outputsandtargets-
forward(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputsfrom neural network and regressiontargets.outputsshould be of shape , where is the number of samples, is the number of features. Should containfloatingpoint values.targetsshould be in the same shapeoutputsand be offloatdata type as well.- Returns
Scalar
tensor- Return type
-
-
class
torchtraining.metrics.distance.Pairwise(p: float = 2.0, eps: float = 1e-06, reduction=<built-in method mean of type object>)[source]¶ Computes the batchwise pairwise distance between vectors , using specified norm.
- Parameters
p (float, optional) – Degree of
norm. Default:2eps (float, optional) – Epsilon to avoid division by zero. Default:
1e-06reduction (Callable(torch.Tensor) -> Any, optional) – One argument callable getting
torch.Tensorand returning argument after specified reduction. Default:torch.mean(mean across batch, user can usetorchtraining.savers.Meanto get mean across iterations/epochs).
-
forward(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputsfrom neural network and regressiontargets.outputsshould be of shape , where is the number of samples, is the number of features. Should containfloatingpoint values.targetsshould be in the same shapeoutputsand be offloatdata type as well.- Returns
If
reductionis left as default {} is taken and single value returned. Otherwise whateverreductionreturns.- Return type