I am creating a custom loss function. I pulled out relevant test code from pytorch to test the function.
I am getting a failure when the function check_criterion_jacobian is called.
A small example demonstrating the problem can be found here
In the example I expand the input and then perform an elementwise multiplication between a simple function of this and a fixed array. The loss then returns the cross entropy between the target and the result of the elementwise multiplication.
When I remove the element wise multiplication I do not get the error.
I thought at first that I might need to set requires_grad for the variable wrapping the fixed array but the error occurs irrespective of the value of requires_grad.
How do I avoid this error?