Initializer that generates tensors with constant values.

Inherits From: Initializer

Used in the notebooks

Used in the tutorials

Also available via the shortcut function tf.keras.initializers.constant.

Only scalar values are allowed. The constant value provided must be convertible to the dtype requested when calling the initializer.


# Standalone usage:
initializer = tf.keras.initializers.Constant(3.)
values = initializer(shape=(2, 2))
# Usage in a Keras layer: