Shortcuts

torchtraining.metrics.regression

class torchtraining.metrics.regression.AbsoluteError(reduction=<built-in method mean of type object>)[source]

Absolute error between outputs and targets.

Parameters

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 use torchtraining.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 regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

If reduction is left as default mean is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor

class torchtraining.metrics.regression.AdjustedR2(p: int)[source]

Adjusted R2 score between outputs and targets.

Parameters

p (int) – Number of explanatory terms in model.

forward(data)[source]
Parameters

data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing outputs from neural network and regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

Scalar tensor

Return type

torch.Tensor

class torchtraining.metrics.regression.MaxError[source]

Maximum error between outputs and targets.

forward(data)[source]
Parameters

data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing outputs from neural network and regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

Scalar tensor

Return type

torch.Tensor

class torchtraining.metrics.regression.R2[source]

R2 score between outputs and targets.

forward(data)[source]
Parameters

data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing outputs from neural network and regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

Scalar tensor

Return type

torch.Tensor

class torchtraining.metrics.regression.RegressionOfSquares(reduction=<built-in method sum of type object>)[source]

Regression of squares between outputs and targets.

Parameters

reduction (Callable, optional) – One argument callable getting torch.Tensor and returning torch.Tensor. Default: torch.sum (sum of all elements, user can use torchtraining.savers.Sum to get sum across iterations/epochs).

forward(data)[source]
Parameters

data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing outputs from neural network and regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

If reduction is left as default sum is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor

class torchtraining.metrics.regression.SquaredError(reduction=<built-in method mean of type object>)[source]

Squared error between outputs and targets.

Parameters

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 use torchtraining.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 regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

If reduction is left as default mean is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor

class torchtraining.metrics.regression.SquaredLogError(reduction=<built-in method mean of type object>)[source]

Squared log error between outputs and targets.

Parameters

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 use torchtraining.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 regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

If reduction is left as default mean is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor

class torchtraining.metrics.regression.SquaresOfResiduals(reduction=<built-in method sum of type object>)[source]

Square of residuals between outputs and targets.

Parameters

reduction (Callable, optional) – One argument callable getting torch.Tensor and returning torch.Tensor. Default: torch.sum (sum of all elements, user can use torchtraining.savers.Sum to get sum across iterations/epochs).

forward(data)[source]
Parameters

data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing outputs from neural network and regression targets. outputs should be of shape (N,)(N, *) , where NN is the number of samples. Should contain floating point values. targets should be in the same shape outputs and be of float data type as well.

Returns

If reduction is left as default sum is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor

class torchtraining.metrics.regression.TotalOfSquares(reduction=<built-in method sum of type object>)[source]

Total of squares of single tensor.

Parameters

reduction (Callable, optional) – One argument callable getting torch.Tensor and returning torch.Tensor. Default: torch.sum (sum of all elements, user can use torchtraining.savers.Sum to get sum across iterations/epochs).

forward(data)[source]
Parameters

data (torch.Tensor) – Tensor containing float data of any shape. Usually targets.

Returns

If reduction is left as default {} is taken and single value returned. Otherwise whatever reduction returns.

Return type

torch.Tensor