UniformTuckerTensorTrain.apply#
- t3toolbox.uniform_tucker_tensor_train.UniformTuckerTensorTrain.apply(vecs)#
def apply( self, vecs: Sequence[NDArray], # len=d, ith elm_shape=vec_stack+(Ni,) ) -> NDArray: # shape=vec_stack+stack_shape (a scalar per stack element)
Contract the represented tensor with vectors in all modes, without forming it (shares
ut3_apply(); a scalar per stack element).Precondition-free (exact for any cores). Uniform mirror of
apply().Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.uniform_tucker_tensor_train as ut3 >>> np.random.seed(0) >>> x = ut3.UniformTuckerTensorTrain.from_t3(t3.TuckerTensorTrain.randn((10, 11, 12), (5, 6, 4), (1, 2, 3, 1))) >>> ww = (np.random.randn(10), np.random.randn(11), np.random.randn(12)) >>> print(bool(np.allclose(x.apply(ww), np.einsum('ijk,i,j,k->', x.to_dense(), *ww)))) True