TensorNetwork icon indicating copy to clipboard operation
TensorNetwork copied to clipboard

Support initialization of an arbitrary-backend Tensor from a numpy array or nested list

Open alewis opened this issue 5 years ago • 5 comments

alewis avatar Sep 28 '20 12:09 alewis

Numpy array should always work given you use backend.convert_to_tensor. Nested lists behave differently for each backend so that might be harder.

chaserileyroberts avatar Sep 28 '20 14:09 chaserileyroberts

Fair enough. Probably just from an array is fine.

alewis avatar Sep 29 '20 12:09 alewis

Hey, Is this issue still still open?

MikeMerz avatar Oct 08 '20 13:10 MikeMerz

Yep, all yours. I think we aren't going to support nested lists, but it would be good if initialization in an arbitrary backend could be done from a numpy array:

A = np.zeros(shape, dtype)
At = tn.Tensor(A, backend="numpy") # produces a tn.Tensor with the numpy backend
At_tf = tn.Tensor(A, backend="tensorflow") # produces a tn.Tensor with the TensorFlow backend

alewis avatar Oct 08 '20 14:10 alewis

@alewis Hey, I tried running the snippet in the last comment and it seems to work fine, did someone already write this?

MikeMerz avatar Oct 14 '20 13:10 MikeMerz