shapes 1205 and 120 not aligned 5 dim 1 != 120 dim 0
This error message typically occurs when trying to perform an operation between two arrays where the shape of the arrays are not compatible. In this case, the first array has a shape of (120, 5) which means it has 120 rows and 5 columns. The second array has a shape of (120,) which means it has 120 elements but only one column.
The error message is telling you that the number of columns in the first array does not match the number of rows in the second array. This prevents the operation from being performed since the arrays are not aligned.
To fix this error, you will need to reshape one of the arrays so that their shapes match. You could reshape the second array to have a shape of (120, 1) by using the numpy reshape function. This will add an extra dimension to the array and make it compatible with the first array.
For example:
import numpy as np
array1 = np.random.rand(120, 5)
array2 = np.random.rand(120)
# Reshape array2 to have a shape of (120, 1)
array2 = np.reshape(array2, (120, 1))
# Now the arrays have compatible shapes and can be used in operations
result = array1 + array2
Alternatively, you could transpose the first array so that it has a shape of (5, 120) and then perform the operation. However, this may not be appropriate depending on the context of your problem
原文地址: http://www.cveoy.top/t/topic/hxb7 著作权归作者所有。请勿转载和采集!