Tensor 操作#

基本操作#

mars.tensor.copyto

Copies values from one array to another, broadcasting as necessary.

形状操作#

mars.tensor.reshape

Gives a new shape to a tensor without changing its data.

mars.tensor.ravel

Return a contiguous flattened tensor.

变换#

mars.tensor.moveaxis

Move axes of a tensor to new positions.

mars.tensor.rollaxis

Roll the specified axis backwards, until it lies in a given position.

mars.tensor.swapaxes

Interchange two axes of a tensor.

mars.tensor.core.Tensor.T

Same as self.transpose(), except that self is returned if self.ndim < 2.

mars.tensor.transpose

Permute the dimensions of a tensor.

修改维度#

mars.tensor.atleast_1d

Convert inputs to tensors with at least one dimension.

mars.tensor.atleast_2d

View inputs as tensors with at least two dimensions.

mars.tensor.atleast_3d

View inputs as tensors with at least three dimensions.

mars.tensor.broadcast_to

Broadcast an tensor to a new shape.

mars.tensor.broadcast_arrays

Broadcast any number of arrays against each other.

mars.tensor.expand_dims

Expand the shape of a tensor.

mars.tensor.squeeze

Remove single-dimensional entries from the shape of a tensor.

修改 Tensor 类型#

mars.tensor.asarray

Convert the input to an array.

合并 Tensor#

mars.tensor.concatenate

Join a sequence of arrays along an existing axis.

mars.tensor.stack

Join a sequence of tensors along a new axis.

mars.tensor.column_stack

Stack 1-D tensors as columns into a 2-D tensor.

mars.tensor.dstack

Stack tensors in sequence depth wise (along third axis).

mars.tensor.hstack

Stack tensors in sequence horizontally (column wise).

mars.tensor.vstack

Stack tensors in sequence vertically (row wise).

拆分 Tensor#

mars.tensor.split

Split a tensor into multiple sub-tensors.

mars.tensor.array_split

Split a tensor into multiple sub-tensors.

mars.tensor.dsplit

Split tensor into multiple sub-tensors along the 3rd axis (depth).

mars.tensor.hsplit

Split a tensor into multiple sub-tensors horizontally (column-wise).

mars.tensor.vsplit

Split a tensor into multiple sub-tensors vertically (row-wise).

对 Tensor 分块#

mars.tensor.tile

Construct a tensor by repeating A the number of times given by reps.

mars.tensor.repeat

Repeat elements of a tensor.

添加和删除元素#

mars.tensor.delete

Return a new array with sub-arrays along an axis deleted.

mars.tensor.insert

Insert values along the given axis before the given indices.

mars.tensor.append

Append values to the end of an array.

mars.tensor.unique

Find the unique elements of a tensor.

元素重排#

mars.tensor.flip

Reverse the order of elements in a tensor along the given axis.

mars.tensor.fliplr

Flip tensor in the left/right direction.

mars.tensor.flipud

Flip tensor in the up/down direction.

mars.tensor.reshape

Gives a new shape to a tensor without changing its data.

mars.tensor.roll

Roll tensor elements along a given axis.