[Solved]: python np zeros TypeError: data type not understood

I am executing following code on the jupyter notebook:

embeddings_matrix = np.zeros(5000,100)

then I am getting this error:

---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last) in ()----> 1 embeddings_matrix = np.zeros(5000,100)TypeError: data type not understood

Solution:

If you see numpy doc:

numpy.zeros

numpy.zeros(shape, dtype=float, order='C')
Return a new array of given shape and type, filled with zeros.

Parameters:

shape: int or tuple of ints
Shape of the new array, e.g., (2, 3) or 2.

dtype : data-type, optional
The desired data-type for the array, e.g., numpy.int8. Default is numpy.float64.

order : {‘C’, ‘F’}, optional, default: ‘C’
Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.

Returns:

out : ndarray
Array of zeros with the given shape, dtype, and order.

 

Now you can see numpy.zeros either take int or tuple, So to make both parameters as tuple use two small brackets.

embeddings_matrix = np.zeros((5000,100))