Hi,
I implement a custom loss function (forward and backward). However, I donot know how to check whether the loss function is correctly implemented or not. I try to follow gradcheck: http://pytorch.org/docs/master/notes/extending.html
While it is not very clear how to use the gradcheck. Can anyone provide some help? Thanks.
class WeightedDiceLoss4Organs(Function):
def __init__(self, *args, **kwargs):
pass
def forward(self, inputs, targets, save=True):
if save:
self.save_for_backward(inputs, targets)
.....
def backward(self, grad_output):
inputs, _ = self.saved_tensors # we need probabilities for input
print 'type(grad_output): ',type(grad_output)
........