Tensor creation routines (mygrad.tensor_creation)#

Array-Like#

tensor(arr_like[, dtype, constant, copy, ndmin])

Create a tensor

asarray(a[, dtype, order])

Convert the input to an array.

astensor(t[, dtype, constant])

Convert the input to a tensor.

Ones and zeros#

ones(shape[, dtype, constant])

Return a Tensor of the given shape and type, filled with ones.

ones_like(other[, dtype, shape, constant])

Return a Tensor of the same shape and type as the given, filled with ones.

zeros(shape[, dtype, constant])

Return a Tensor of the given shape and type, filled with zeros.

zeros_like(other[, dtype, shape, constant])

Return a Tensor of the same shape and type as the given, filled with zeros.

eye(N[, M, k, dtype, constant])

Return a 2D Tensor with ones on the diagonal and zeros elsewhere.

identity(n[, dtype, constant])

Return the identity Tensor; a square Tensor with 1s on the main diagonal and 0s elsewhere.

full(shape, fill_value[, dtype, constant])

Return a Tensor of the given shape and type, filled with fill_value.

full_like(other, fill_value[, dtype, shape, ...])

Return a Tensor of the same shape and type as the given, filled with fill_value.

empty(shape[, dtype, constant])

Return a new Tensor of the given shape and type, without initializing entries.

empty_like(other[, dtype, shape, constant])

Return a new Tensor of the same shape and type as the given array.

Numerical ranges#

arange([start,] stop[, step,][, dtype, constant])

Return a Tensor with evenly-spaced values within a given interval.

linspace(start, stop[, num, endpoint, ...])

Return a Tensor with evenly-spaced numbers over a specified interval.

logspace(start, stop[, num, endpoint, base, ...])

Return a Tensor with evenly-spaced numbers over a specified interval on a log scale.

geomspace(start, stop[, num, endpoint, ...])

Return a Tensor with evenly-spaced values in a geometric progression.