Tensor manipulation routines (mygrad.tensor_manip)#

Changing array shape#

ravel(a, *[, constant])

Flattens contents of a tensor into a contiguous 1-D array.

reshape(a, newshape, *[, constant])

Returns a tensor with a new shape, without changing its data.

Tensor.flatten(*[, constant])

Return a copy of the tensor collapsed into one dimension.

Transpose-like operations#

moveaxis(a, source, destination, *[, constant])

Move axes of a tensor to new positions.

roll(a, shift[, axis, constant])

Roll tensor elements along a given axis.

swapaxes(a, axis1, axis2, *[, constant])

Interchange two axes of a tensor.

Tensor.T

Same as self.transpose(), except that self is returned if self.ndim < 2 and a view of the underlying data is utilized whenever possible.

transpose(a, *axes[, constant])

Permute the dimensions of a tensor.

Changing number of dimensions#

atleast_1d()

Convert inputs to tensors with at least one dimension.

atleast_2d()

Convert inputs to tensors with at least one dimension.

atleast_3d()

Convert inputs to tensors with at least one dimension.

broadcast_to(a, shape, *[, constant])

Broadcast a tensor to a new shape.

expand_dims(a, axis, *[, constant])

Expand the dimensions of a tensor by adding a new axis.

squeeze(a[, axis, constant])

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

Joining tensors#

concatenate([axis, out, constant])

Join a sequence of tensors along an existing axis.

stack([axis, out, constant])

Join a sequence of tensors along a new axis.

Tiling tensors#

repeat(a, repeats[, axis, constant])

Repeat elements of a tensor.