Addition of an Array and a Tensor returns an object Array instead of a Tensor
adtzlr opened this issue · comments
np.eye(3) + tr.Tensor(np.eye(3))
This one is ok
tr.Tensor(np.eye(3)) + np.eye(3)
It's because the first line calls np.eye(3).__add__(tr.Tensor(np.eye(3)))
. This should raise an Error, so that tr.Tensor(np.eye(3)).__radd__(np.eye(3))
is called. "Unfortunately", an array iterates through its items and performs the addition.
This could help: https://stackoverflow.com/questions/45947152/custom-class-with-add-to-add-with-numpy-array