UniformTuckerTensorTrain.save#

t3toolbox.uniform_tucker_tensor_train.UniformTuckerTensorTrain.save(file)#
def save(
        self,
        file,  # path or open file object to write the .npz to
) -> None:

Save to a .npz file (2 supercores + 2 rank masks + the shape ints). See load().

Examples

>>> import numpy as np
>>> import t3toolbox.uniform_tucker_tensor_train as ut3
>>> np.random.seed(0)
>>> x = ut3.UniformTuckerTensorTrain.randn((5, 6, 7), (3, 4, 2), (1, 3, 2, 1))
>>> fname = 'ut3_file.npz'
>>> x.save(fname)
>>> x2 = ut3.UniformTuckerTensorTrain.load(fname)
>>> print(float(np.linalg.norm(x2.to_dense() - x.to_dense())))
0.0
>>> x2.shape                                       # the static shape survives the round-trip
(5, 6, 7)
>>> print([str(m.dtype) for m in x2.masks.data])   # rank masks come back numpy (host) bool
['bool', 'bool']
Return type:

None