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: Expanded size of Tensor must match existing dimension for non-singleton dimension #6

Open
deepanmathibalan opened this issue Dec 3, 2019 · 2 comments

Comments

@deepanmathibalan
Copy link

For the line "cl2h[:,:,rx::rate,ry::rate] = clow*norm" in merge_func.py, I am getting the following runtime error "Expanded size of Tensor must match existing dimension for non-singleton dimension". This happens when the size of chigh is not exactly twice the size of clow. Specifically this happens when clow dimensions are odd numbers. Can you provide a solution on how to fix this issue?

@bilel-bj
Copy link

bilel-bj commented Dec 9, 2019

Me the same problem. I did not find a solution.

Traceback (most recent call last): File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/SHAB_main.py", line 44, in <module> main(opt) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/main_process.py", line 76, in main test_phase_video(opt,net,testloader,log_save_path=log_save_path) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Val.py", line 124, in test_phase_video merge_res = net.parse_merge(div_res) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Network/SDCNet.py", line 346, in parse_merge tclow = count_merge_low2high_batch(tclow,tchigh) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Network/merge_func.py", line 22, in count_merge_low2high_batch cl2h[:,:,rx::rate,ry::rate] = clow*norm RuntimeError: The expanded size of the tensor (34) must match the existing size (33) at non-singleton dimension 2. Target sizes: [1, 1, 34, 60]. Tensor sizes: [33, 60]

@xhp-hust-2018-2011
Copy link
Owner

In “load_data_V2.py” Line 114, we pad the image to be divisible by 64. So only C0 will be odd, C1 and C2 will be evens. Meanwhile, C1 (C2) will be exactly 2x size of C0(C1). This error is probably caused by incorrect padding.

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

3 participants