As seen in the below quote, you have a nan in your landmarks tensor, which is resulting in loss being nan.



 Mona_Jalal:

landmarks are:  tensor([[0.6599, 0.3325, 0.9300, 0.4307, 0.4980, 0.4253, 0.5592, 0.4422],
        [0.6730, 0.3241, 0.9179, 0.4374, 0.4347, 0.4132, 0.6810, 0.4051],
        [   nan,    nan, 0.7744, 0.1895, 0.4347, 0.1655, 0.5532, 0.4563],
        [0.6756, 0.3249, 0.8314, 0.1680, 0.4729, 0.1804, 0.6929, 0.4272],
        [0.6549, 0.3249, 0.9408, 0.3244, 0.3970, 0.3190, 0.5713, 0.4147],
        [0.6748, 0.3306, 0.9381, 0.2490, 0.4738, 0.1830, 0.6729, 0.4199],
        [0.6570, 0.3229, 0.9421, 0.4145, 0.4118, 0.3836, 0.6070, 0.4105],
        [0.6572, 0.3253, 0.9408, 0.3957, 0.4401, 0.3661, 0.5459, 0.4449]],
       device='cuda:0')