Creation#
zeros#
def zeros(shape: 'ShapeLike', *, dtype: 'DType | None' = None, device: 'Device | None' = None, is_traced: 'bool' = False):
Create a tensor filled with zeros.
ones#
def ones(shape: 'ShapeLike', *, dtype: 'DType | None' = None, device: 'Device | None' = None, is_traced: 'bool' = False):
Create a tensor filled with ones.
full#
def full(shape: 'ShapeLike', value: 'Number', *, dtype: 'DType | None' = None, device: 'Device | None' = None, is_traced: 'bool' = False):
Create a tensor filled with a constant value.
constant#
def constant(value: 'NestedArray | Number', *, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a tensor from a constant value.
arange#
def arange(start: 'int' = 0, stop: 'int | None' = None, step: 'int' = 1, *, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a tensor with evenly spaced values.
uniform#
def uniform(shape: 'ShapeLike' = (), low: 'float' = 0.0, high: 'float' = 1.0, *, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a tensor with uniform random values.
normal#
def normal(shape: 'ShapeLike' = (), mean: 'float' = 0.0, std: 'float' = 1.0, *, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a tensor with Gaussian (normal) random values.
gaussian#
def gaussian(shape: 'ShapeLike' = (), mean: 'float' = 0.0, std: 'float' = 1.0, *, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a tensor with Gaussian (normal) random values.
hann_window#
def hann_window(window_length: 'int', *, periodic: 'bool' = True, dtype: 'DType | None' = None, device: 'Device | None' = None):
Create a 1D Hann window tensor.
triu#
def triu(x: 'Tensor', k: 'int' = 0) -> 'Tensor':
Upper triangular part of a matrix.
tril#
def tril(x: 'Tensor', k: 'int' = 0) -> 'Tensor':
Lower triangular part of a matrix.
zeros_like#
def zeros_like(x: 'Tensor') -> 'Tensor':
Create a tensor of zeros with the same shape/dtype/device/sharding as x.
ones_like#
def ones_like(x: 'Tensor') -> 'Tensor':
Create a tensor of ones with the same shape/dtype/device/sharding as x.
full_like#
def full_like(x: 'Tensor', value: 'Number') -> 'Tensor':
Create a tensor filled with value, matching x’s properties.