TuckerTensorTrain.segment#
- t3toolbox.tucker_tensor_train.TuckerTensorTrain.segment(start, stop)#
def segment( self, start: int, # requires stop > start stop: int, # requires stop > start ) -> 'TuckerTensorTrain':
Extract contiguous segment of this TuckerTensorTrain. Segments must have length at least one.
- Parameters:
start (int) – Starting index for segment. Requires
stop > start.stop (int) – Stopping index for segment. Requires
stop > start.
- Returns:
Segment of this TuckerTensorTrain, with
shape=(N(start), ..., N(stop-1)).- Return type:
- Raises:
ValueError – If
stop <= start.
See also
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> randn = np.random.randn >>> tucker_cores = (randn(4,14), randn(5,15), randn(6,16), randn(7,17)) >>> tt_cores = (randn(2,4,3), randn(3,5,2), randn(2,6,2), randn(2,7,4)) >>> x = t3.TuckerTensorTrain(tucker_cores, tt_cores) >>> x01 = x.segment(1,3) >>> print(x01.core_shapes) (((5, 15), (6, 16)), ((3, 5, 2), (2, 6, 2)))