UT3Tangent.probe_derivatives#
- t3toolbox.uniform_manifold.UT3Tangent.probe_derivatives(ww, pp, order)#
def probe_derivatives( self, ww: typ.Sequence[NDArray], # probe 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 ) -> typ.Tuple[NDArray, ...]: # len=d, ith elm_shape=(order+1,)+W+K+C+(Ni,)
Symmetric directional derivatives of
probe(), in one repeated directionP(pp): the forward Riemannian Jacobian derivativesy_i^(t) = d^t/ds^t [probe(X + s P)]_i|_0fort=0..order(order 0 isprobe(); the bare𝒥, no gaugeΠ).ww/ppshare the sample stackW; stacksorder + W + K + C. Uniform mirror ofprobe_derivatives().No numerical precondition (gauge-invariant, any frame). Structural precondition (hard error):
P(pp) shares the sample stackWand mode dims ofX(ww).See also
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.uniform_tucker_tensor_train as ut3 >>> import t3toolbox.uniform_manifold as ut3m >>> np.random.seed(0) >>> x = ut3.UniformTuckerTensorTrain.from_t3(t3.TuckerTensorTrain.randn((10, 11, 12), (5, 6, 4), (1, 2, 3, 1))) >>> v = ut3m.UNIFORM_COREWISE.randn(ut3m.UNIFORM_MANIFOLD.frame(x)) >>> 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)) >>> zj = v.probe_derivatives(ww, pp, 3) >>> print([z.shape for z in zj]) # (order+1,) + (Ni,) [(4, 10), (4, 11), (4, 12)] >>> print([bool(np.allclose(z[0], z0)) for z, z0 in zip(zj, v.probe(ww))]) # order 0 == probe [True, True, True]
Pmust matchX’s sample stack and mode dims (structural, raises):>>> v.probe_derivatives(ww, (np.random.randn(10), np.random.randn(11), np.random.randn(99)), 3) ... Traceback (most recent call last): ... ValueError