Fewshot_Detection
Fewshot_Detection copied to clipboard
RuntimeError: The expanded size of the tensor (3) must match the existing size (864) at non-singleton dimension 3. Target sizes: [32, 3, 3, 3]. Tensor sizes: [864]
Sorry for troubling you. When I run train_meta.py and load weightfile, a runtimeerror occured:
logging to backup/metayolo_novel0_neg1 class_scale 1
RuntimeErrorTraceback (most recent call last)
~/lkj项目/FSD_yolo/darknet_meta.py in load_weights(self, weightfile) 376 batch_normalize = int(block['batch_normalize']) 377 if batch_normalize: --> 378 start = load_conv_bn(buf, start, model[0], model[1]) 379 else: 380
~/lkj项目/FSD_yolo/cfg.py in load_conv_bn(buf, start, conv_model, bn_model) 453 bn_model.running_mean.copy_(torch.from_numpy(buf[start:start+num_b])); start = start + num_b 454 bn_model.running_var.copy_(torch.from_numpy(buf[start:start+num_b])); start = start + num_b --> 455 conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w 456 return start 457
RuntimeError: The expanded size of the tensor (3) must match the existing size (864) at non-singleton dimension 3. Target sizes: [32, 3, 3, 3]. Tensor sizes: [864]
Do you know what's wrong with this? Thank you so much.
The folder "backup" is created manually. Is that right?
Yes.
Hi, thank you for your quickly reply. But I haven't solved the error mentioned above till now. Is it related with Broadcasting semantics in Pytorch? Thanks a lot.
Are you using the cfg files in the instruction?
Yes, I use cfg files and change the path of train set and val set.
Maybe you can refer to this. https://github.com/marvis/pytorch-yolo3/issues/15
Thank you for your opinions. I have tried these methods mentioned in the link above but solutions didn't work.My torch version is 1.3.0.
Our code is implemented with PyTorch 0.3.1 and Python 2.7. You may want to try this version.
Thank you for your suggestion! I think I should try it.
I had the same issue, so I switched to PyTorch 0.3.1 but now I get
import torch.utils.checkpoint as cp
ImportError: No module named checkpoint
@DL-Alva Were you able to resolve the error with the The expanded size of the tensor (3) ?
if yes, how and what version of Torch did you end up using?
This ended up working, although not sure what I did to resolve the issue.
I did install torchvision==0.4.2, and installed torch 0.4.0 then reinstalled torch 0.3.1.
torch==0.3.1, python2.7, torchvision==0.2.0 work
Sorry for troubling you. When I run train_meta.py and load weightfile, a runtimeerror occured:
logging to backup/metayolo_novel0_neg1
class_scale 1 RuntimeErrorTraceback (most recent call last) in () 14 region_loss = model.loss 15 ---> 16 model.load_weights(weightfile) 17 model.print_network()
~/lkj项目/FSD_yolo/darknet_meta.py in load_weights(self, weightfile) 376 batch_normalize = int(block['batch_normalize']) 377 if batch_normalize: --> 378 start = load_conv_bn(buf, start, model[0], model[1]) 379 else: 380
~/lkj项目/FSD_yolo/cfg.py in load_conv_bn(buf, start, conv_model, bn_model) 453 bn_model.running_mean.copy_(torch.from_numpy(buf[start:start+num_b])); start = start + num_b 454 bn_model.running_var.copy_(torch.from_numpy(buf[start:start+num_b])); start = start + num_b --> 455 conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w 456 return start 457
RuntimeError: The expanded size of the tensor (3) must match the existing size (864) at non-singleton dimension 3. Target sizes: [32, 3, 3, 3]. Tensor sizes: [864]
Do you know what's wrong with this? Thank you so much.
这个问题我觉得可以修改,cfg.py第456行.copy_()如下: size_conv = conv_model.weight.data.size() # 这两行改过,将被复制的shape改成一致的 conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w]).view(size_conv)); start = start + num_w
copy_()复制和被复制的shape不一样,所有如果改了应该就可以。但是,我还遇到其他一些问题,或许换了pytorch的版本能解决问题!
Have you solved this problem? @DL-Alva @90000mileswind I also met this problem. Thanks for your help.
Same errors. I use cuda8, pytorch 0.3.1, python 2.7 and torchvision 0.2.0. Have you solved this problem? @DL-Alva
@90000mileswind 你好,我也是同样的问题。view(size_conv)是否与存储的预训练数据顺序一致呢?
Our code is implemented with PyTorch 0.3.1 and Python 2.7. You may want to try this version.
Hello, can you tell me the CUDA version you used in the test?
It is OK using pytorch0.3.1-py2.7
Open cfg.py
file at line 455 and change to
conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w]).reshape_as(conv_model.weight.data)); start = start + num_w
worked for me
Open
cfg.py
file at line 455 and change toconv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w]).reshape_as(conv_model.weight.data)); start = start + num_w
worked for me that really works!! thanks!!!!!!