ValueError: shapes (50,2) and (1,2) not aligned: 2 (dim 1) != 1 (dim 0)
时间: 2023-12-14 19:02:09 浏览: 79
Python解析json之ValueError: Expecting property name enclosed in double quotes: line 1 column 2(char 1)
This error occurs when trying to perform an operation that requires two arrays to have the same shape or compatible shapes, but their shapes are not compatible.
In this specific case, the error message indicates that you are trying to perform an operation between two arrays with shapes (50,2) and (1,2), respectively. The error occurs because the second array has only one row, while the first one has 50 rows, and the operation cannot be performed because the dimensions are not compatible.
To resolve this error, you need to ensure that the shapes of the arrays you are working with are compatible for the operation you want to perform. You can reshape the arrays or use broadcasting to make sure their shapes match.
阅读全文