File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
snntoolbox/parsing/model_libs Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -64,15 +64,14 @@ def load(path, filename):
6464 if os .path .exists (model_path ):
6565 break
6666 assert model_path , "Pytorch state_dict not found at {}" .format (model_path )
67- model_pytorch .load_state_dict (torch .load (model_path ,
68- map_location = map_location ))
69-
70- # state_dict = torch.load(model_path, map_location=map_location)['state_dict']
71- # new_state_dict = {}
72- # for k, v in state_dict.items():
73- # k = str(k).replace('module.', '')
74- # new_state_dict[k] = v
75- # model_pytorch.load_state_dict(new_state_dict, strict=False)
67+ try :
68+ model_pytorch .load_state_dict (
69+ torch .load (model_path , map_location = map_location ))
70+ except RuntimeError as e :
71+ print ("WARNING: Ignored mismatch when loading pytorch state_dict." )
72+ print (e )
73+ model_pytorch .load_state_dict (
74+ torch .load (model_path , map_location = map_location ), strict = False )
7675
7776 # Switch from train to eval mode to ensure Dropout / BatchNorm is handled
7877 # correctly.
You can’t perform that action at this time.
0 commit comments