Create instance of fixed shape tensor extension type with shape and optional names of tensor dimensions and indices of the desired logical ordering of dimensions.
DataType
Data type of individual tensor elements.
tuple
or list
of integers
The physical shape of the contained tensors.
tuple
or list
of strings
, default None
Explicit names to tensor dimensions.
tuple
or list
integers
, default None
Indices of the desired ordering of the original dimensions. The indices contain a permutation of the values [0, 1, .., N-1]
where N is the number of dimensions. The permutation indicates which dimension of the logical layout corresponds to which dimension of the physical tensor. For more information on this parameter see Fixed shape tensor.
FixedShapeTensorType
Examples
Create an instance of fixed shape tensor extension type:
>>> import pyarrow as pa >>> tensor_type = pa.fixed_shape_tensor(pa.int32(), [2, 2]) >>> tensor_type FixedShapeTensorType(extension<arrow.fixed_shape_tensor[value_type=int32, shape=[2,2]]>)
Inspect the data type:
>>> tensor_type.value_type DataType(int32) >>> tensor_type.shape [2, 2]
Create a table with fixed shape tensor extension array:
>>> arr = [[1, 2, 3, 4], [10, 20, 30, 40], [100, 200, 300, 400]] >>> storage = pa.array(arr, pa.list_(pa.int32(), 4)) >>> tensor = pa.ExtensionArray.from_storage(tensor_type, storage) >>> pa.table([tensor], names=["tensor_array"]) pyarrow.Table tensor_array: extension<arrow.fixed_shape_tensor[value_type=int32, shape=[2,2]]> ---- tensor_array: [[[1,2,3,4],[10,20,30,40],[100,200,300,400]]]
Create an instance of fixed shape tensor extension type with names of tensor dimensions:
>>> tensor_type = pa.fixed_shape_tensor(pa.int8(), (2, 2, 3), ... dim_names=['C', 'H', 'W']) >>> tensor_type.dim_names ['C', 'H', 'W']
Create an instance of fixed shape tensor extension type with permutation:
>>> tensor_type = pa.fixed_shape_tensor(pa.int8(), (2, 2, 3), ... permutation=[0, 2, 1]) >>> tensor_type.permutation [0, 2, 1]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4