Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Dimension Mismatch in Element-wise Operation #1

Open
euisuh opened this issue Sep 27, 2023 · 0 comments
Open

RuntimeError: Dimension Mismatch in Element-wise Operation #1

euisuh opened this issue Sep 27, 2023 · 0 comments

Comments

@euisuh
Copy link

euisuh commented Sep 27, 2023

I encountered a runtime error while working on a project that involves performing element-wise operations between three tensors: batch_data, weights, and bias. The error message I received is as follows:
RuntimeError: The size of tensor a (3) must match the size of tensor b (0) at non-singleton dimension 1

The issue arises from a dimension mismatch along dimension 1 when trying to perform element-wise operations. Here are the shapes of the tensors involved:
batch_data shape: torch.Size([30, 3, 224, 224])
weights shape: torch.Size([30, 9, 224, 224])
bias shape: torch.Size([30, 3, 224, 224])

I have resolved the issue by using the bias tensor as it is, without dividing it into three parts. This approach correctly adds the bias term to each channel of the batch_data without any channel-wise adjustments, and it resolved the dimension mismatch error. If you have any further questions or encounter related issues, please feel free to reopen or create a new issue. Thank you for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant