. Advertisement .
..3..
. Advertisement .
..4..
I am trying to write a python that returns the invalid answer. I don’t know where the incorrect command is in the “valueerror: shape mismatch: objects cannot be broadcast to a single shape”. My detail is:
r_num = n*(np.add.reduce(xm*ym))
, and I end up with the warning message:
ValueError: shape mismatch: objects cannot be broadcast to a single shape
Pls, suggest the best answer to fix it.
The cause: The different shapes of your x and y inputs make them contradictory with element-wise multiplication.
Solution: Change the shape of your input x and y so that they have the same shape. By this way, they can compatible with the element-wise multiplication.