RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 7 but got size 6 for tensor number 1 in the list
时间: 2023-11-06 08:41:42 浏览: 146
pytorch dataloader 取batch_size时候出现bug的解决方式
This error occurs when there is a size mismatch between tensors in a list. In this case, the error message indicates that tensor number 1 in the list has an expected size of 7 but got a size of 6.
To fix this error, you need to ensure that all tensors in the list have the same size in all dimensions except dimension 1. Check the code that creates the list of tensors and make sure that all tensors have the same size. If the sizes are different, you can resize the tensors using PyTorch's `resize()` function or create new tensors with the correct size.
阅读全文