jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
455 stars 107 forks source link

Using torch as autodiff_backend #106

Closed yuxuanzhang1995 closed 2 years ago

yuxuanzhang1995 commented 2 years ago

I got this:

TypeError: tensordot(): argument 'other' (position 2) must be Tensor, not numpy.ndarray

when I tried to use torch as autodiff_backend, which I believe is faster than tensorflow; I did not have this issue when I used tf before.

jcmgray commented 2 years ago

Hi @yuxuanzhang1995, it's hard to say without some more details and example code to reproduce, but assuming you are talking about the TNOptimizer my guess is that you need to specify loss_constants so that any extra tensors not included in the main tensor network can be converted to the right backend (tensorflow/jax/autograd happily accept numpy arrays as constant inputs, but torch does not...).

yuxuanzhang1995 commented 2 years ago

Exactly what I need. Thanks!