Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

In numpy, I have two "arrays", X is (m,n) and y is a vector (n,1)

using

X*y

I am getting the error

ValueError: operands could not be broadcast together with shapes (97,2) (2,1)

When (97,2)x(2,1) is clearly a legal matrix operation and should give me a (97,1) vector

1 Answer

0 votes
by (106k points)
edited by

Use the below mentioned code to get rid of the error:-

import numpy 

numpy.dot(numpy.ones([97, 2]), numpy.ones([2, 1])).shape

To know more about this you can have a look at the following video tutorial:-

For more information, kindly refer to our Python Certification course.

Browse Categories

...