KeyError: 'weight' when using resnet18 following mpc_cifar.py code
See original GitHub issueI run into this error, when I try using CrypTen with resnet18 model for my code
KeyError Traceback (most recent call last)
<ipython-input-11-8baf0b8ce013> in <module>
16
17 input_size = get_input_size(val_loader, batch_size)
---> 18 private_model = construct_private_model(input_size, hosp_models[i])
19 validate(loader=val_loader, model=private_model)
20 print('\n')
<ipython-input-5-19f29188bd4f> in construct_private_model(input_size, model)
15 else:
16 model_upd = LeNet()
---> 17 private_model = crypten.nn.from_pytorch(model_upd, dummy_input).encrypt(src=0)
18 return private_model
19
~/Downloads/mila project/udacity_DP_FL/CrypTen/crypten/nn/onnx_converter.py in from_pytorch(pytorch_model, dummy_input)
35 # construct CrypTen model:
36 f = _from_pytorch_to_bytes(pytorch_model, dummy_input)
---> 37 crypten_model = from_onnx(f)
38 f.close()
39
~/Downloads/mila project/udacity_DP_FL/CrypTen/crypten/nn/onnx_converter.py in from_onnx(onnx_string_or_file)
122 """Converts an onnx model to a CrypTen model"""
123 converter = FromOnnx(onnx_string_or_file)
--> 124 crypten_model = converter.to_crypten()
125 return crypten_model
126
~/Downloads/mila project/udacity_DP_FL/CrypTen/crypten/nn/onnx_converter.py in to_crypten(self)
184 # add CrypTen module to graph
185 crypten_module = crypten_class.from_onnx(
--> 186 parameters=parameters, attributes=attributes
187 )
188 node_output_name = list(node.output)[0]
~/Downloads/mila project/udacity_DP_FL/CrypTen/crypten/nn/module.py in from_onnx(parameters, attributes)
1584
1585 # initialize module:
-> 1586 in_channels = parameters["weight"].size(1)
1587 out_channels = parameters["weight"].size(0)
1588 module = Conv2d(
KeyError: 'weight'
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Key error in giving weights to nodes in python - Stack Overflow
Let's assume the loop to assign weight to the parent starts with node 457. par then is 45 which has more than one...
Read more >'unexpected key "module.module.module.conv1.weight" in ...
I am getting the following error while trying to load a saved model. KeyError: 'unexpected key "module.encoder.embedding.weight" in state_dict' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also, got the email - will look now.
@gmuraru Here you are keyerrorweightwhenusingresnet18followingmpc_cifar_p.zip