Solved by ptrblck in post #2 
              
              
                Currently you are passing two tensors to your loss function, which don’t require gradients and are decoupled of your models. 
last_Y1 is still the zero tensor, while Xt is the image you’ve captured using openCV. 
Usually you would pass some model output as the first input and a target as the second …