flax.linen.initializers.constant#

flax.linen.initializers.constant(value, dtype=<class 'jax.numpy.float64'>)[source]#

Builds an initializer that returns arrays full of a constant value.

Parameters
  • value – the constant value with which to fill the initializer.

  • dtype – optional; the initializer’s default dtype.

>>> import jax, jax.numpy as jnp
>>> initializer = jax.nn.initializers.constant(-7)
>>> initializer(jax.random.PRNGKey(42), (2, 3), jnp.float32)
Array([[-7., -7., -7.],
       [-7., -7., -7.]], dtype=float32)