<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/array_ops.py#L2599-L2658) |

Creates a tensor with all elements set to zero.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.zeros`](https://www.tensorflow.org/api_docs/python/tf/zeros)

<br />

    tf.zeros(
        shape,
        dtype=https://www.tensorflow.org/api_docs/python/tf/dtypes#float32,
        name=None,
        layout=None
    )

### Used in the notebooks

| Used in the guide | Used in the tutorials |
|---|---|
| - [Training checkpoints](https://www.tensorflow.org/guide/checkpoint) - [Multilayer perceptrons for digit recognition with Core APIs](https://www.tensorflow.org/guide/core/mlp_core) - [Better performance with the tf.data API](https://www.tensorflow.org/guide/data_performance) - [Optimizers with Core APIs](https://www.tensorflow.org/guide/core/optimizers_core) - [Better performance with tf.function](https://www.tensorflow.org/guide/function) | - [Custom layers](https://www.tensorflow.org/tutorials/customization/custom_layers) - [Learned data compression](https://www.tensorflow.org/tutorials/generative/data_compression) - [Using DTensors with Keras](https://www.tensorflow.org/tutorials/distribute/dtensor_keras_tutorial) - [Integrated gradients](https://www.tensorflow.org/tutorials/interpretability/integrated_gradients) - [Multilevel Modeling Primer in TensorFlow Probability](https://www.tensorflow.org/probability/examples/Multilevel_Modeling_Primer) |

See also [`tf.zeros_like`](https://www.tensorflow.org/api_docs/python/tf/zeros_like), [`tf.ones`](https://www.tensorflow.org/api_docs/python/tf/ones), [`tf.fill`](https://www.tensorflow.org/api_docs/python/tf/fill), [`tf.eye`](https://www.tensorflow.org/api_docs/python/tf/eye).

This operation returns a tensor of type `dtype` with shape `shape` and
all elements set to zero.

    tf.zeros([3, 4], tf.int32)
    <tf.Tensor: shape=(3, 4), dtype=int32, numpy=
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int32)>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `shape` | A `list` of integers, a `tuple` of integers, or a 1-D `Tensor` of type `int32`. |
| `dtype` | The DType of an element in the resulting `Tensor`. |
| `name` | Optional string. A name for the operation. |
| `layout` | Optional, [`tf.experimental.dtensor.Layout`](https://www.tensorflow.org/api_docs/python/tf/experimental/dtensor/Layout). If provided, the result is a [DTensor](https://www.tensorflow.org/guide/dtensor_overview) with the provided layout. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` with all elements set to zero. ||

<br />