NumPy - Broadcasting
What is the issue with this code snippet?
import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([1, 2, 3]) print(a + b)
import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([1, 2, 3]) print(a + b)
a shape is (2, 2), b shape is (3,). These shapes are incompatible for broadcasting.a + b raises a ValueError due to incompatible shapes.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions