Hi Thomas!



 thomas:

I checked the forward and backward graph and all the function of the loss function are present except softmax, is it normal ?


This is the hint.


def custom_loss(delta):
    def loss(y_pred, y_true):
        y_pred_softmax = nn.Softmax(dim=1)(y_pred)
        y_pred_softmax_clipped = torch.clamp(y_pred, 1e-8, 1 - 1e-8)
        log_likelihood = y_true * torch.log(y_pred_softmax_clipped)
        return torch.sum(-log_likelihood * delta)
    return loss



You pass y_pred (rather than y_pred_softmax) to torch.clamp().
This looks like a simple typo, and the effect is that the call to
nn.Softmax() is bypassed.  (Note, you don’t have this typo in your
original tensorflow code.)
Best.
K. Frank