TuckerTensorTrain.probe_derivatives#

t3toolbox.tucker_tensor_train.TuckerTensorTrain.probe_derivatives(ww, pp, order)#
def probe_derivatives(
        self,
        ww:     Sequence[NDArray],  # probe vectors X,        len=d, elm_shape=W+(Ni,)
        pp:     Sequence[NDArray],  # perturbation vectors P, len=d, elm_shape=W+(Ni,)
        order:  int,                # highest derivative order
) -> Sequence[NDArray]:             # len=d, elm_shape=(order+1,)+W+C+(Ni,)

Symmetric directional derivatives of probing this Tucker tensor train, in one repeated direction.

Returns, for each mode i, the stack y_i^(t) = d^t/ds^t [probe(X + s P)]_i|_0 for t=0..order – the derivative analogue of probe(), perturbing every probe vector in the same direction P. Index 0 is the ordinary probe(). Stacks order + W + C (order outermost; probe stack W, T3 stack C). X (ww) and P (pp) must share the sample stack W. (For the gradient w.r.t. the cores, see probe_corewise_derivatives_transpose(); for the Riemannian Jacobian use T3Tangent.probe_derivatives.) See docs/symmetric_probe_derivatives.tex.

Examples

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> np.random.seed(0)
>>> x = t3.TuckerTensorTrain.randn((14, 15, 16), (4, 5, 6), (1, 3, 2, 1))
>>> ww = (np.random.randn(14), np.random.randn(15), np.random.randn(16))
>>> pp = (np.random.randn(14), np.random.randn(15), np.random.randn(16))
>>> zj = x.probe_derivatives(ww, pp, 3)
>>> print([z.shape for z in zj])           # (order+1,) + (Ni,)
[(4, 14), (4, 15), (4, 16)]
>>> print([bool(np.allclose(z[0], z0)) for z, z0 in zip(zj, x.probe(ww))])  # order 0 == probe
[True, True, True]
Parameters:
  • ww (collections.abc.Sequence[NDArray])

  • pp (collections.abc.Sequence[NDArray])

  • order (int)

Return type:

collections.abc.Sequence[NDArray]