t3toolbox.weighted_tucker_tensor_train.wt3_add ============================================== .. py:function:: t3toolbox.weighted_tucker_tensor_train.wt3_add(A: WeightedTuckerTensorTrain, B: WeightedTuckerTensorTrain, squash: bool = True, use_jax: bool = False) -> WeightedTuckerTensorTrain Add two weighted Tucker tensor trains. .. rubric:: Examples >>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.weighted_tucker_tensor_train as wt3 >>> randn = np.random.randn >>> x0 = t3.t3_corewise_randn((6,7,8), (5,6,7), (2,3,3,1), stack_shape=(4,)) >>> x_tucker_vectors = tuple([randn(4, 5), randn(4, 6), randn(4, 7)]) >>> x_tt_vectors = tuple([randn(4, 2), randn(4, 3), randn(4, 3), randn(4, 1)]) >>> x_weights = wt3.EdgeVectors(x_tucker_vectors, x_tt_vectors) >>> x = wt3.WeightedTuckerTensorTrain(x0, x_weights) >>> y0 = t3.t3_corewise_randn((6,7,8), (2,4,2), (1,3,1,2), stack_shape=(4,)) >>> y_tucker_vectors = tuple([randn(4, 2), randn(4, 4), randn(4, 2)]) >>> y_tt_vectors = tuple([randn(4, 1), randn(4, 3), randn(4, 1), randn(4, 2)]) >>> y_weights = wt3.EdgeVectors(y_tucker_vectors, y_tt_vectors) >>> y = wt3.WeightedTuckerTensorTrain(y0, y_weights) >>> x_plus_y = wt3.wt3_add(x, y) >>> x_dense = x.contract_edge_weights_into_cores().to_dense() >>> y_dense = y.contract_edge_weights_into_cores().to_dense() >>> x_plus_y_dense = x_plus_y.contract_edge_weights_into_cores().to_dense() >>> print(np.linalg.norm(x_dense + y_dense - x_plus_y_dense)) 1.3834329073101016e-13