tf.fill

Creates a tensor filled with a scalar value.

Used in the notebooks

Used in the guide Used in the tutorials

See also tf.ones, tf.zeros, tf.one_hot, tf.eye.

This operation creates a tensor of shape dims and fills it with value.

For example:

tf.fill([2, 3], 9)
<tf.Tensor: shape=(2, 3), dtype=int32, numpy=
array([[9, 9, 9],
       [9, 9, 9]], dtype=int32)>

tf.fill evaluates at graph runtime and supports dynamic shapes based on other runtime tf.Tensors, unlike tf.constant(value, shape=dims), which embeds the value as a Const node.

dims A 1-D sequence of non-negative numbers. Represents the shape of the output tf.Tensor. Entries should be of type: int32, int64.
value A value to fill the returned tf.Tensor.
name Optional string. The name of the output