actually you point out that the graph might not be recognized, and this makes sense that with x and x_expected the computation through a network would not be taking place, so no learnable parameters would be involved, and so there shouldnt be any gradients for them. are x and x_expected themselves coming through some other computation graph that you expect to learn through your new loss?