Hello,
I’m training a model to predict landmarks on faces. My lossfunction looks like in the following:
"
logits = model_ft(inputs)
out=torch.sigmoid(logits)
loss_temp=(torch.abs(out-target))**potenz
loss_temp[torch.isnan(target)]=0
loss=torch.mean(loss_temp)
loss.backward()
"
Not all Landmarks are everytime provided, so thats the reason I assign the loss a zero for empty Landmarks. When I use the potenz=1 it works fine, but if I change it to potenz=2 or every other value like potenz=1.0001 than the gradients of the weights of the model getting nan after the first backward pass.
Why is that?