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 - outputsand- targets- 
forward(data)[source]¶
- Parameters
- data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing - outputsfrom neural network and regression- targets.- outputsshould be of shape , where is the number of samples, is the number of features. Should contain- floatingpoint values.- targetsshould be in the same shape- outputsand be of- floatdata 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.Tensorand returning argument after specified reduction. Default:- torch.mean(mean across batch, user can use- torchtraining.savers.Meanto get mean across iterations/epochs).
 
 - 
forward(data)[source]¶
- Parameters
- data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing - outputsfrom neural network and regression- targets.- outputsshould be of shape , where is the number of samples, is the number of features. Should contain- floatingpoint values.- targetsshould be in the same shape- outputsand be of- floatdata type as well.
- Returns
- If - reductionis left as default {} is taken and single value returned. Otherwise whatever- reductionreturns.
- Return type