fn
ones_
→Tensorones_(tensor: Tensor)Fill tensor in-place with ones.
Convenience wrapper around constant_ with val=1.0. The
canonical use case is the gain (gamma) parameter of normalisation
layers (BatchNorm, LayerNorm, GroupNorm) so the layer initially acts
as the identity scaling.
Parameters
tensorTensorTensor to fill in place; any shape is accepted.
Returns
Tensortensor (mutated) for chaining.
Notes
Equivalent to constant_ (tensor, 1.0).
Examples
>>> import lucid
>>> from lucid.nn.init import ones_
>>> gamma = lucid.empty(64)
>>> ones_(gamma)