Skip to content

Latest commit

 

History

History
62 lines (30 loc) · 1.44 KB

mnn.layer.NllLossLayer.md

File metadata and controls

62 lines (30 loc) · 1.44 KB

class NllLossLayer

This is to simulate PyTorch NLL layer which computes a negative expectation loss. Labels are passed in as integer indices.

method __init__

__init__()

method backward

backward()

In this case, the gradient vector w.r.t. $q$ is simply an almost-zero vector $v$ where $v_l = -1$.


method forward

forward(inputs, feedbacks=None)

$$ \ell(q) = -\sum^n_{i=0} p_i q_i = -q_l $$

where $p \in {0, 1}$ indicates true probability, but in actual implementation, the label is given as an index $l \in \mathbb{N}$.


method step

step(lr=0.01)