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
outputs
andtargets
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network and regressiontargets
.outputs
should be of shape , where is the number of samples, is the number of features. Should containfloating
point values.targets
should be in the same shapeoutputs
and be offloat
data 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:2
eps (float, optional) – Epsilon to avoid division by zero. Default:
1e-06
reduction (Callable(torch.Tensor) -> Any, optional) – One argument callable getting
torch.Tensor
and returning argument after specified reduction. Default:torch.mean
(mean across batch, user can usetorchtraining.savers.Mean
to get mean across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network and regressiontargets
.outputs
should be of shape , where is the number of samples, is the number of features. Should containfloating
point values.targets
should be in the same shapeoutputs
and be offloat
data type as well.- Returns
If
reduction
is left as default {} is taken and single value returned. Otherwise whateverreduction
returns.- Return type