tf.keras.initializers.Ones

Initializer that generates tensors initialized to 1.

Inherits From: Initializer

Used in the notebooks

Used in the guide

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

Examples:

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

Methods

from_config

View source

Instantiates an initializer from a configuration dictionary.

Example:

initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)

Args
config A Python dictionary, the output of get_config.

Returns
A tf.keras.initializers.Initializer instance.

get_config

View source