fn
uniform_
→Tensoruniform_(tensor: Tensor, a: float = 0.0, b: float = 1.0)Initialise tensor in-place with samples from a uniform distribution.
Each entry is drawn independently from . The
function mutates tensor in place and returns the same object so
calls can be chained or used as a one-liner inside a model
constructor.
Parameters
tensorTensorTensor to fill in place; any shape is accepted.
afloat= 0.0Lower bound of the uniform interval. Default
0.0.bfloat= 1.0Upper bound of the uniform interval. Default
1.0.Returns
Tensortensor (mutated) for chaining.
Notes
The resulting distribution has mean and variance
Higher-level schemes such as xavier_uniform_ and
kaiming_uniform_ are thin wrappers over this function with
bounds computed from the fan factors of tensor.
Examples
>>> import lucid
>>> from lucid.nn.init import uniform_
>>> w = lucid.empty(4, 4)
>>> uniform_(w, -0.1, 0.1)