TypeError: data type not understood in numpy

1.6k views Asked by At

I was working with numpy for Neural Networks and I am facing This Error

TypeError: data type not understood

and my code was

a = np.array([7, 7, 7], [7, 7, 7])
print(np.argmax(np.array([[5, 6, 7], [1, 2, 3]]), axis = 0, a))
1

There are 1 answers

0
yonatansc97 On BEST ANSWER

Just to clarify @dimay 's comment: np.array receives two inputs, with the first being the data itself, and the second being the datatype. When you want two rows, you should be giving np.array a list of lists. np.array tried to create a 1-d array with the elements [7, 7, 7], and the other [7, 7, 7] was thought to be a dtype, which leads to the error.