ValueError: could not broadcast input array from shape (1080,1917,3) into shape (1917,1080,3)
时间: 2024-04-29 09:22:50 浏览: 57
This error occurs when you are trying to reshape or transpose an array, but the new shape you are trying to create is not compatible with the original shape. In this case, you are trying to reshape an array of shape (1080, 1917, 3) into a shape of (1917, 1080, 3), but the two shapes are not compatible.
To fix this error, you need to make sure that the new shape you are trying to create has the same number of elements as the original shape. In this case, you can try transposing the array instead of reshaping it. To transpose an array, you can use the `numpy.transpose()` function:
```
import numpy as np
# create a 3D array
arr = np.zeros((1080, 1917, 3))
# transpose the array
arr_transposed = np.transpose(arr, (1, 0, 2))
# now arr_transposed has shape (1917, 1080, 3)
```
In this example, we are transposing the array along the first two dimensions, so the new shape will be (1917, 1080, 3). Note that we are passing a tuple `(1, 0, 2)` to the `np.transpose()` function, which specifies the new order of the dimensions.
阅读全文