## What is numpy.zeros()?

numpy.zeros() or np.zeros Python function is used to create a matrix full of zeroes. numpy.zeros() in Python can be used when you initialize the weights during the first iteration in TensorFlow and other statistic tasks.

numpy.zeros() function Syntax

`numpy.zeros(shape, dtype=float, order='C')`

Python numpy.zeros() Parameters

Here,

• Shape: is the shape of the numpy zero array
• Dtype: is the datatype in numpy zeros. It is optional. The default value is float64
• Order: Default is C which is an essential row style for numpy.zeros() in Python.

Python numpy.zeros() Example

```import numpy as np
np.zeros((2,2))```

Output:

```array([[0., 0.],
[0., 0.]])```

Example of numpy zero with Datatype

``` import numpy as np
np.zeros((2,2), dtype=np.int16)```

Output:

```array([[0, 0],
[0, 0]], dtype=int16)```

## What is numpy.ones()?

np.ones() function is used to create a matrix full of ones. numpy.ones() in Python can be used when you initialize the weights during the first iteration in TensorFlow and other statistic tasks.

Python numpy.ones() Syntax

`numpy.ones(shape, dtype=float, order='C')`

Python numpy.ones() Parameters

Here,

• Shape: is the shape of the np.ones Python array
• Dtype: is the datatype in numpy ones. It is optional. The default value is float64
• Order: Default is C which is an essential row style.

Python numpy.ones() 2D Array with Datatype Example

```import numpy as np
np.ones((1,2,3), dtype=np.int16)
```

Output:

```array([[[1, 1, 1],
[1, 1, 1]]], dtype=int16)			```

YOU MIGHT LIKE: