Creates a tensor with all elements set to zero.
Aliases:
tf.compat.v1.zerostf.compat.v2.zeros
tf.zeros(
shape,
dtype=tf.dtypes.float32,
name=None
)
Used in the guide:
Betterperformancewithtf.functionandAutoGraphMigrateyourTensorFlow1codetoTensorFlow2``TheKerasfunctionalAPIinTensorFlow``Trainingcheckpoints``WritingcustomlayersandmodelswithKeras
Used in the tutorials:
Betterperformancewithtf.functionCustomlayersCustomtrainingwithtf.distribute.StrategyCustomtraining:basicsImagecaptioningwithvisualattention``NeuralmachinetranslationwithattentionThis operation returns a tensor of typedtypewithshapeshapeand all elements set to zero.
For example:
tf.zeros([3, 4], tf.int32) # [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Args:
shape: A list of integers, a tuple of integers, or a 1-DTensorof typeint32.dtype: The type of an element in the resultingTensor.name: Anamefor the operation (optional).
Returns:
A Tensor with all elements set to zero.