RuntimeError: mat1 and mat2 shapes cannot be multiplied (8x2352 and 784x8)
时间: 2024-01-22 19:03:27 浏览: 79
This error occurs because the number of columns in the first matrix (mat1) is not equal to the number of rows in the second matrix (mat2). In order to perform matrix multiplication, the number of columns in the first matrix must match the number of rows in the second matrix.
In this case, mat1 has 8 rows and 2352 columns, while mat2 has 784 rows and 8 columns. Since the number of columns in mat1 (2352) is not equal to the number of rows in mat2 (784), the matrices cannot be multiplied together.
To fix this error, you will need to ensure that the matrices have compatible shapes for multiplication. This could involve reshaping or transposing one or both matrices so that the number of columns in the first matrix matches the number of rows in the second matrix.
阅读全文