Open cherrypiecoco opened 5 years ago
encountered the same problem
@electroncastle i have already solved by load the state_dict using model.load_state_dict(torch.load(PATH), strict=False), but the inference results seems wrong😂, reference from this thread, it actually also has other solutions.
@zhibo I'm so glad that you have sorted things out! Sorry for bothering you, but where did you add that "model.load_state_dict(torch.load(PATH), strict=False)" line in which part of the code? I'm quite new to PyTorch (not alone Python) so your advice will be greatly appreciated! :)
@zhibo I'm so glad that you have sorted things out! Sorry for bothering you, but where did you add that "model.load_state_dict(torch.load(PATH), strict=False)" line in which part of the code? I'm quite new to PyTorch (not alone Python) so your advice will be greatly appreciated! :)
about Line #286 in amnet.py, just by adding a param (strict=False) for load_state_dict function
I see. Thank you! I have changed the code accordingly and it seemed like working until I face another error... Did you face this similar error message as well?
Traceback (most recent call last):
File "main.py", line 106, in
I see. Thank you! I have changed the code accordingly and it seemed like working until I face another error... Did you face this similar error message as well?
Traceback (most recent call last): File "main.py", line 106, in main() File "main.py", line 89, in main result.write_stdout() File "C:\Users.....\AMNet-master\amnet.py", line 50, in write_stdout print(str(i)+'\t'+image + (' '*(max_len-len(image)+5)) + str(round(prediction,3)) + ' \t' + str(round(target,3)) ) TypeError: type Tensor doesn't define round method
i guess that cause you didn't prepare the ground truth data (that is the target
), you can simply comment out this part + ' \t' + str(round(target,3)) )
or prepare the training data done
Hello, Thank you for sharing your code. While I've been trying to follow your guideline in window-based environment, I could train model but eval is fail.
amnet.py,line 494. for data, target, _ in test_loader: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.
Hello, Thank you for sharing your code. While I've been trying to follow your guideline in window-based environment, I see this error message.
Traceback (most recent call last): File "C:\Users........\AmNet-master\amnet.py", line 284, in load_checkpoint self.model.load_weights(cpnt['model']) File "C:\Users........\AmNet-master\amnet_model.py", line 334, in load_weights raise KeyError('missing keys in state_dict: "{}"'.format(missing)) KeyError: 'missing keys in state_dict: "{\'core_cnn.core_cnn.layer2.2.bn3.num_batches_tracked\', \'core_cnn.core_cnn.layer3.3 .bn3.num_batches_tracked\', \'core_cnn.core_cnn.layer4.0.bn1.num_batches_tracked\', \'core_cnn.core_cnn.layer3.4.bn1.num_batc hes_tracked\', \'core_cnn.core_cnn.layer1.2.bn2.num_batches_tracked\', ......,}
RuntimeError: Error(s) in loading state_dict for AMemNetModel: Unexpected key(s) in state_dict: "e11.weight", "e11.bias", "eh2.weight", "eh2.bias", "eh12.weight", "eh12.bias", "eh3 0.weight", "eh30.bias", "eh31.weight", "eh31.bias", "eh11.weight", "eh11.bias", "eh22.weight", "eh22.bias", "regnet2.weight", "regnet2.bias".
Could you kindly advise me how to solve this issue? I think the runtime error is raised due to the missing keys in state_dict error. I'm relatively new to this world and your comment will be super helpful! Thank you.