Np.zeros (dim, 1), giving the data type incomprehensible

I am very new to python and numpy. Trying to put into action a row vector with zeros as follows w = np.zeros (dim, 1)

Getting the error "TypeError: data type is incomprehensible". Appreciate any help. Thanks

+4
source share
1 answer

See the documentation at np.zeros

If you call it the way you did, the size dimand the argument of the data type dtypeare 1, which is not a valid data type.

Decision

import numpy as np
dim = 3 # number of entries
shp = (dim, 1) # shape tuple
x = np.zeros(shp) # second argument 'dtype' is not used, default is 'float'
print(x)
+3
source

Source: https://habr.com/ru/post/1684606/


All Articles