Fewshot_Detection icon indicating copy to clipboard operation
Fewshot_Detection copied to clipboard

About the loading model

Open tjzjp opened this issue 6 years ago • 2 comments

Traceback (most recent call last): File "train_meta.py", line 87, in model.load_weights(weightfile) File "/home/zjp/Fewshot_Detection/darknet_meta.py", line 381, in load_weights start = load_conv_bn(buf, start, model[0], model[1]) File "/home/zjp/Fewshot_Detection/cfg.py", line 461, in load_conv_bn conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w RuntimeError: The size of tensor a (3) must match the size of tensor b (864) at non-singleton dimension 3

sorry, When I loaded your pretrained model darknet19_448.conv.23, It came out the above problem. Thank you!

tjzjp avatar Oct 26 '19 13:10 tjzjp

Please check your PyTorchb (0.3.1) and Python (2.7) versions.

bingykang avatar Oct 29 '19 02:10 bingykang

For higher version pytorch (e.g. pytorch1.2), when loading weights for Conv2D, we can reshape the 1-D weights to 4-D weights. in cfg.py, in function load_conv_bn, we can conv.model.weight.data.copy_(torch.from_numpy(buff[start:start+num_w]).reshape(conv_model.weight.data.shape))

vasgaowei avatar Jun 09 '20 15:06 vasgaowei