sugartensor.sg_metric module

sugartensor.sg_metric.sg_accuracy(tensor, opt)[source]

Returns accuracy of predictions.

Args:

tensor: A Tensor. Probability distributions or unscaled prediction scores. opt:

target: A ‘Tensor`. Labels.
Returns:
A Tensor of the same shape as tensor. Each value will be 1 if correct else 0.

For example,

` tensor = [[20.1, 18, -4.2], [0.04, 21.1, 31.3]] target = [[0, 1]] tensor.sg_accuracy(target=target) => [[ 1.  0.]] `