TensorNetwork icon indicating copy to clipboard operation
TensorNetwork copied to clipboard

Serialization for Tensor

Open tanlin2013 opened this issue 4 years ago • 6 comments

In numpy, this can be acheived with *.npy or *.npz extension. Just wonder, given all supported backends in TensorNetwork, is there a unified way to save a bunch of tensors in a compressed and binary format file?

I have read the documentation for a while, but still couldn't find the saving functionality. Or perhaps I miss it somewhere :)

thanks!

tanlin2013 avatar Mar 31 '21 07:03 tanlin2013

Hi @tanlin2013 , unfortunately this is currently not supported. The Node class supports serialization to HDF5 format using h5py. You could initialize a Node using the data-array in Tensor and save that, if this helps.

mganahl avatar Mar 31 '21 12:03 mganahl

If you are interested in contributing, PRs are always welcome!!

mganahl avatar Mar 31 '21 15:03 mganahl

Sounds nice! I would love to.

I have a small repo tnpy that is built on top of TensorNetwork. I'm actaully about to implement TDVP and DMT for real-time evo. That's why I need to store MPS generated by DMRG.

tanlin2013 avatar Apr 01 '21 11:04 tanlin2013

nice! Let us know of any additional missing functionality, and we'll try to add it.

mganahl avatar Apr 06 '21 06:04 mganahl

There is serialization support that exports networks to json, with array formats stored in their backend specified format. Currently the only backend that currently implements the the serialize/deserialize_tensor methods is the numpy backend, but this can be very easily added to other backends.

#824

jacksonwb avatar Apr 06 '21 16:04 jacksonwb

tf.io.serialize_tensor( tensor, name=None )

thanujkumar1999 avatar Aug 31 '21 07:08 thanujkumar1999