Loss Functions

MSELoss

class recoder.losses.MSELoss(confidence=0, reduction='elementwise_mean')[source]

Computes the weighted mean squared error loss.

The weight for an observation x:

\[w = 1 + confidence \times x\]

and the loss is:

\[\ell(x, y) = w \cdot (y - x)^2\]
Parameters:
  • confidence (float, optional) – the weighting of positive observations.
  • reduction (string, optional) – Specifies the reduction to apply to the output: ‘none’ | ‘elementwise_mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘elementwise_mean’: the sum of the output will be divided by the number of elements in the output, ‘sum’: the output will be summed. Default: ‘elementwise_mean’

MultinomialNLLLoss

class recoder.losses.MultinomialNLLLoss(reduction='elementwise_mean')[source]

Computes the negative log-likelihood of the multinomial distribution.

\[\ell(x, y) = L = - y \cdot \log(softmax(x))\]
Parameters:reduction (string, optional) – Specifies the reduction to apply to the output: ‘none’ | ‘elementwise_mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘elementwise_mean’: the sum of the output will be divided by the number of elements in the output, ‘sum’: the output will be summed. Default: ‘elementwise_mean’