Movatterモバイル変換


[0]ホーム

URL:


Skip to content
tensorstore.stack(layers:Iterable[TensorStore|Spec],axis:int=0,*,read:bool|None=None,write:bool|None=None,context:Context|None=None,transaction:Transaction|None=None,rank:int|None=None,dtype:DTypeLike|None=None,domain:IndexDomain|None=None,shape:Iterable[int]|None=None,dimension_units:Iterable[Unit|str|Real|tuple[Real,str]|None]|None=None,schema:Schema|None=None)TensorStore

Virtually stacks a sequence ofTensorStore layers along a new dimension.

>>>store=ts.stack([...ts.array([1,2,3,4],dtype=ts.uint32),...ts.array([5,6,7,8],dtype=ts.uint32)...])>>>storeTensorStore({  'context': {'data_copy_concurrency': {}},  'driver': 'stack',  'dtype': 'uint32',  'layers': [    {      'array': [1, 2, 3, 4],      'driver': 'array',      'dtype': 'uint32',      'transform': {        'input_exclusive_max': [1, 4],        'input_inclusive_min': [0, 0],        'output': [{'input_dimension': 1}],      },    },    {      'array': [5, 6, 7, 8],      'driver': 'array',      'dtype': 'uint32',      'transform': {        'input_exclusive_max': [2, 4],        'input_inclusive_min': [1, 0],        'output': [{'input_dimension': 1}],      },    },  ],  'schema': {'domain': {'exclusive_max': [2, 4], 'inclusive_min': [0, 0]}},  'transform': {'input_exclusive_max': [2, 4], 'input_inclusive_min': [0, 0]},})>>>awaitstore.read()array([[1, 2, 3, 4],       [5, 6, 7, 8]], dtype=uint32)>>>store=ts.stack([...ts.array([1,2,3,4],dtype=ts.uint32),...ts.array([5,6,7,8],dtype=ts.uint32)...],...axis=-1)>>>storeTensorStore({  'context': {'data_copy_concurrency': {}},  'driver': 'stack',  'dtype': 'uint32',  'layers': [    {      'array': [1, 2, 3, 4],      'driver': 'array',      'dtype': 'uint32',      'transform': {        'input_exclusive_max': [4, 1],        'input_inclusive_min': [0, 0],        'output': [{'input_dimension': 0}],      },    },    {      'array': [5, 6, 7, 8],      'driver': 'array',      'dtype': 'uint32',      'transform': {        'input_exclusive_max': [4, 2],        'input_inclusive_min': [0, 1],        'output': [{'input_dimension': 0}],      },    },  ],  'schema': {'domain': {'exclusive_max': [4, 2], 'inclusive_min': [0, 0]}},  'transform': {'input_exclusive_max': [4, 2], 'input_inclusive_min': [0, 0]},})>>>awaitstore.read()array([[1, 5],       [2, 6],       [3, 7],       [4, 8]], dtype=uint32)
Parameters:
layers:Iterable[TensorStore|Spec]

Sequence of layers to stack. If a layer is specified as aSpec rather than aTensorStore, it must have a knowndomain and will be opened on-demand as needed for individualread and write operations.

axis:int=0

New dimension along which to stack. A negative number counts from the end.

read:bool|None=None

Allow read access. Defaults toTrue if neitherread norwrite is specified.

write:bool|None=None

Allow write access. Defaults toTrue if neitherread norwrite is specified.

context:Context|None=None

Shared resource context. Defaults to a new (unshared) context with defaultoptions, as returned bytensorstore.Context(). To share resources,such as cache pools, between multiple open TensorStores, you must specify acontext.

transaction:Transaction|None=None

Transaction to use for opening/creating, and for subsequent operations. Bydefault, the open is non-transactional.

Note

To perform transactional operations using aTensorStore that waspreviously opened without a transaction, useTensorStore.with_transaction.

rank:int|None=None

Constrains the rank of the TensorStore. If there is an index transform, therank constraint must match the rank of theinput space.

dtype:DTypeLike|None=None

Constrains the data type of the TensorStore. If a data type has already beenset, it is an error to specify a different data type.

domain:IndexDomain|None=None

Constrains the domain of the TensorStore. If there is an existingdomain, the specified domain is merged with it as follows:

  1. The rank must match the existing rank.

  2. All bounds must match, except that a finite or explicit bound is permitted tomatch an infinite and implicit bound, and takes precedence.

  3. If both the new and existing domain specify non-empty labels for a dimension,the labels must be equal. If only one of the domains specifies a non-emptylabel for a dimension, the non-empty label takes precedence.

Note that if there is an index transform, the domain must match theinputspace, not the output space.

shape:Iterable[int]|None=None

Constrains the shape and origin of the TensorStore. Equivalent to specifying adomain ofts.IndexDomain(shape=shape).

Note

This option also constrains the origin of all dimensions to be zero.

dimension_units:Iterable[Unit|str|Real|tuple[Real,str]|None]|None=None

Specifies the physical units of each dimension of the domain.

Thephysical unit for a dimension is the physical quantity corresponding to asingle index increment along each dimension.

A value ofNone indicates that the unit is unknown. A dimension-lessquantity can be indicated by a unit of"".

schema:Schema|None=None

Additional schema constraints to merge with existing constraints.


[8]ページ先頭

©2009-2025 Movatter.jp