[SOLVED] Element 0 of tensors does not require grad

Hi,

I try an experiment to replace softmax with integer-representation, my repo is here;

I met an error of;

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

What does the error mean? and how to solve the error?

Best,
S.Takano

Hi,

This means that you tried to backward on a Tensor that does not require gradients.
This is most likely because you did a non-differentiable operation on your Tensor.
In particular, your BinaryRepresentation. The output does not depend on the input in any differentiable way.

@albanD -san,

Thank you for your pointing out my misunderstanding.
It was caused by if statement which makes the impossible to differentiate.
Now it works (but I get other error).

Best,
S.Takano