clika_runtime.nn.init
Initializers: fill a tensor in place from a named distribution or law.
Every function here writes through in-place operations on the tensor it
is given and returns that same object, so the call composes with a
:class:~clika_runtime.nn.Parameter and reads as in a model's
reset_parameters::
import clika_runtime.nn.init as init
init.kaiming_uniform_(self.weight, a=math.sqrt(5))
init.zeros_(self.bias)
init.trunc_normal_(self.pos_embed, std=0.02)
Fan-in and fan-out read the runtime's channels-last weight layouts: a
linear weight is [out, in], a convolution weight is
[out, *kernel, in / groups], and a transposed-convolution weight is
[in, *kernel, out / groups]. The trailing axis carries the input
channels and the middle axes the kernel, so fan_in is the trailing
extent times the kernel elements and fan_out the leading extent times
the kernel elements; a 2-d weight reads fan_in = shape[1],
fan_out = shape[0]. The values agree with the fans of the same weight
in the channels-first layout.
A tensor without storage (one declared under meta init, or a slot a layer
has not bound yet) cannot be written: every initializer raises
RuntimeError there. Materialize it first (Module.to_empty) or load a
checkpoint into it. orthogonal_ and sparse_ are absent: they need
a QR factorization the operator set does not provide.
Randomness comes from the device's generator; seed it through the
device namespace. The generator parameter is accepted for call-site
compatibility and must be None.
| Name | Kind |
|---|
| functions | module functions |