You don’t show how you got the gradients. Did you use build_graph=True?
Also, for linear functions the gradient will not depend on the parameters, this will also look similar to your error message.
Best regards
Thomas