That means that you have another issue 
Can you give the code that shows how you get train_full and  generated_full_X and w_x_X?
In particular:

Do they require gradients?
Do you compute them in a differentiable manner outside of the loop?