The AttributeError is raised, as you’ve most likely forgotten to add the super().__init__() call into the __init__ method.



 scollazo:

Apart from all of these, do you suggest that I have to code the Mass_and_v class all based in PyTorch, not using numpy?


Yes, I would try to avoid using other libraries if possible, since you would break the computation graph and PyTorch won’t be able to track these operations. If really necessary, you could write a custom autograd.Function and define the forward as well as backward methods manually.