I want to create a custom loss function in Torch which is a modification of ClassNLLCriterion. Concretely, ClassNLLCriterion loss is:
loss(x, class) = -x[class]
I want to modify this to be:
loss(x, class) = -x[class]*K
where K
is a function of the network input, NOT the network weights or network output. Thus K
can be treated as a constant.
What is the easiest way of implementing this custom criterion? The updateOutput()
function seems straightforward, but how do I modify the updateGradInput()
function?