Metrics¶
Module implementing metrics for torch tensors
-
borch.metrics.
accuracy
(rv)¶ Calculates the accuracy, i.e. how much agreement between two long tensors. It will return values between 0 and 1. :param rv: an observed RandomVariable. :type rv: borch.RandomVariable
- Returns
tensor, with the calculated accuracy
Examples
>>> from borch import RandomVariable, distributions >>> import torch >>> rv = distributions.Categorical(logits=torch.randn(4)) >>> acc = accuracy(rv)
Notes
This function does not support gradient trough it
-
borch.metrics.
all_metrics
(rv)¶ - Calculates all valid performance metrics of an observed RandomVariable,
rv (borch.RandomVariable): an observed RandomVariable.
- Returns
dict, with performance measures
Notes
If no performance measures is defined for the support of the distribution, an empty dict will be returned.
Examples
>>> import torch >>> from borch import distributions >>> rv = distributions.Normal(0, 1) >>> met = all_metrics(rv)
-
borch.metrics.
mean_squared_error
(rv)¶ Measures the averaged element-wise mean squared error of an observed RandomVariable :param rv: an observed RandomVariable. :type rv: borch.RandomVariable
- Returns
tensor, with the mean squared error
Examples
>>> from borch import RandomVariable, distributions >>> import torch >>> rv = distributions.Normal(torch.randn(10), torch.randn(10).exp()) >>> mse = mean_squared_error(rv)