Could you check that your input tensor has values that are between 0 and 1?
You could add the following line to right before your loss call:
assert (input >= 0. & input <= 1.).all()
and see if it’s ever triggered.