padded_start#

t3toolbox.backend.optimizers.padded_start(problem, x0, x_old, oversampling=None, oversampled_passes=None, max_passes=None, tol=None, alternate=None, seed=None, use_jit=False)#
def padded_start(
        problem:             'Problem',
        x0:                  Cores,                     # the zero-padded point at the target ranks (minimal); uniform: bare pair
        x_old:               typ.Optional[typ.Any],     # the old point at minimal ranks (ragged cores / uniform full .data, rank 0 allowed); None = the zero tensor (the cone)

        oversampling:        typ.Optional[int]   = None,   # None = the member's default (ALIGN_OVERSAMPLING = 5); forwarded only when set
        oversampled_passes:  typ.Optional[int]   = None,   # None = 2
        max_passes:          typ.Optional[int]   = None,   # None = 10
        tol:                 typ.Optional[float] = None,   # None = 0.05
        alternate:           typ.Optional[bool]  = None,   # None = True
        seed:                typ.Optional[int]   = None,   # None = ZERO_FRAME_SEED
        use_jit:             bool = False,                 # forwarded to the loop; newton_cg passes its own use_jit
) -> typ.Tuple[
    typ.Any,   # the aligned frame of x0 (ragged frame / uniform frame .data at the level's widths)
    typ.Any,   # movements, as the member returns them (ragged tuple; uniform NaN-padded array)
]:

The frame of x0 aligned with the problem’s misfit gradient: the start of a Newton run after a rank increase (the aligned padded frame with the misfit gradient as its hint; user guide The aligned padded frame).

x0 is the zero-padded point at the target ranks and x_old the old point (None: the zero tensor, the 'cone' reference’s frame). The alignment runs on the geometry’s aligned_padded_frame member against _misfit_gradient_at() of the residual at x0 (at the zero tensor when x_old is None). Unset options take the member’s defaults; max_passes=0 returns the hint-free padded start, and an option it would not read then raises.

Examples

A problem’s aligned frame without running Newton – the route from the frontend least_squares_problem:

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> import t3toolbox.frame_variations_format as bvf
>>> import t3toolbox.manifold as t3m
>>> import t3toolbox.optimizers as topt
>>> import t3toolbox.backend.optimizers as bopt
>>> np.random.seed(0)
>>> shape = (5, 6, 5)
>>> ww = [np.random.randn(60, n) for n in shape]
>>> data = t3.TuckerTensorTrain.randn(shape, (3, 4, 3), (1, 3, 3, 1)).probe(ww)
>>> x_old = t3.TuckerTensorTrain.randn(shape, (2, 2, 2), (1, 2, 2, 1))
>>> x0 = x_old.resize(shape, (3, 4, 3), (1, 3, 3, 1))                 # zero-padded to the target ranks
>>> setup = topt.least_squares_problem(t3m.MANIFOLD, 'probe', ww, data, x0)
>>> frame, movements = bopt.padded_start(setup.problem, setup.x0_cores, x_old.data)
>>> F = bvf.T3Frame(*frame)                                           # rewrap
>>> F.down_ranks, len(movements) <= 10
((3, 4, 3), True)

Newton can start from it (newton_cg(start_frame=...); padded_from=x_old.data does both steps):

>>> lm = setup.problem.local_model(setup.x0_cores, frame=frame)
>>> bool(float(lm.objective) > 0)
True
Parameters:
  • problem (Problem)

  • x0 (Cores)

  • x_old (t3toolbox.backend.common.typ.Optional[t3toolbox.backend.common.typ.Any])

  • oversampling (t3toolbox.backend.common.typ.Optional[int])

  • oversampled_passes (t3toolbox.backend.common.typ.Optional[int])

  • max_passes (t3toolbox.backend.common.typ.Optional[int])

  • tol (t3toolbox.backend.common.typ.Optional[float])

  • alternate (t3toolbox.backend.common.typ.Optional[bool])

  • seed (t3toolbox.backend.common.typ.Optional[int])

  • use_jit (bool)

Return type:

t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Any, t3toolbox.backend.common.typ.Any]