State_dict() for modules inside sequential module

Hi, I want to convert the AlexNet to the fully convolutional alexnet. I’m tryining to reshape the fc weighst into convoutioanl form using the following line:

fcn_model.conv1.load_state_dict({"weight": **alexnet.classifier.1.state_dict()**["weight"].view(6, 6, 4096, 1),"bias"...

but I face a sytax error in this place: alexnet.classifier.1.
So, How should I access the state_dict for the operations inside a nn.Sequential?

Thanks
Saeed

If you need the 1st element of alexnet.classifier just alexnet.classifier[1].sate_dict() will give you an OrderedDict containing weight and bias

1 Like

That’s great
Thanks you so much