mygrad.full#

mygrad.full(shape: Union[Sequence[int], int], fill_value: ArrayLike, dtype: Optional[DTypeLikeReals] = None, *, constant: Optional[bool] = None) Tensor[source]#

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

This docstring was adapted from numpy.full [1]

Parameters
shapeUnion[int, Iterable[int]]

The shape of the output Tensor.

fill_valueArrayLike

The value with which to fill the output Tensor. Note that this function is not differentiable – the resulting tensor will not backprop through fill_value.

The value with which to fill the output Tensor.

dtypeOptional[DTypeLikeReals]

The data type of the output Tensor, or None to match fill_value..

constantOptional[bool]

If True, this tensor is a constant, and thus does not facilitate back propagation.

Defaults to False for float-type data. Defaults to True for integer-type data.

Integer-type tensors must be constant.

Returns
Tensor

A Tensor of fill_value with the given shape and dtype.

References

1

Retrieved from https://numpy.org/doc/stable/reference/generated/numpy.full.html

Examples

>>> import mygrad as mg
>>> mg.full((2, 2), 33)
Tensor([[ 33,  33],
        [ 33,  33]])
>>> mg.full((2, 2), 10)
Tensor([[10, 10],
        [10, 10]])