T3Tangent.apply_derivatives#
- t3toolbox.manifold.T3Tangent.apply_derivatives(ww, pp, order)#
def apply_derivatives( self, ww: typ.Sequence[NDArray], # apply vectors X, len=d, elm_shape=W+(Ni,) pp: typ.Sequence[NDArray], # perturbation vectors P, len=d, elm_shape=W+(Ni,) order: int, # highest derivative order ) -> NDArray: # shape=(order+1,)+W+K+C
Symmetric directional derivatives of applying this tangent vector in all modes.
The all-modes analogue of
probe_derivatives()(and the derivative analogue ofapply()):y^(t) = d^t/ds^t apply(X + s P)|_0fort=0..order(a scalar per stack element). Stacksorder + W + K + C.XandPmust share the sample stackW.See also
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.frame_variations_format as bvf >>> import t3toolbox.manifold as t3m >>> np.random.seed(0) >>> x = t3.TuckerTensorTrain.randn((10, 11, 12), (5, 6, 4), (1, 2, 3, 1)) >>> frame, variations = bvf.t3_orthogonal_representations(x) >>> v = t3m.T3Tangent(frame, variations) >>> ww = (np.random.randn(10), np.random.randn(11), np.random.randn(12)) >>> pp = (np.random.randn(10), np.random.randn(11), np.random.randn(12)) >>> yj = v.apply_derivatives(ww, pp, 3) >>> print(yj.shape) # (order+1,) -- one scalar per order (4,) >>> print(bool(np.allclose(yj[0], v.apply(ww)))) # order 0 == apply True