: stack expects each tensor to be equal size, but got [3, 128, 164] at entry 0 and [3, 128, 128] at entry 1
时间: 2024-02-10 22:54:38 浏览: 118
This error occurs when trying to concatenate or stack tensors with different shapes. In this case, the tensors have different sizes in the second dimension. The first tensor has a size of 164, while the second tensor has a size of 128.
To fix this error, you need to ensure that all tensors have the same shape before concatenating or stacking them. You can either resize the tensors to have the same shape or use padding to ensure that they have the same size.
Alternatively, you can also consider using a different operation to combine the tensors, such as torch.cat() instead of torch.stack(). torch.cat() concatenates tensors along a specified dimension, while torch.stack() stacks tensors along a new dimension.
阅读全文