t3toolbox.weighted_tucker_tensor_train.wt3_inner_product#
- t3toolbox.weighted_tucker_tensor_train.wt3_inner_product(A: WeightedTuckerTensorTrain, B: WeightedTuckerTensorTrain, use_orthogonalization: bool = True, use_jax: bool = False)#
Computes the Hilbert-Schmidt inner product between two Tucker tensor trains.
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_dot_y = wt3.wt3_inner_product(x,y) >>> print(x_dot_y) [ 8.20032492 -8.97264769 -344.13076394 -3.72479156] >>> x_dense = x.contract_edge_weights_into_cores().to_dense() >>> y_dense = y.contract_edge_weights_into_cores().to_dense() >>> print(np.array([np.sum(x_dense[ii] * y_dense[ii]) for ii in range(4)])) [ 8.20032492 -8.97264769 -344.13076394 -3.72479156]