NumPy - Broadcasting
How can you correctly add a 1D NumPy array
b to each column of a 2D array A using broadcasting?b to each column of a 2D array A using broadcasting?A has shape (m, n) and b has shape (n,). To add b to each column, b must be broadcast along rows.b for broadcastingb[np.newaxis, :] changes b shape to (1, n), which can broadcast across A's rows.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions