Extracting weights from previous layers- EfficientNet

Hi Team,
I have trained an image regression model using EfficientNetB5.
I wanted to extract the weights from it’s previous layers because i want to use those weights to further train a boosting model.

Previously I used Densenet and I was able to extract it’s weights using indexing and using forward hooks.

Now since EfficientNet models doesn’t support indexing.
Is their any way to extract the weights from the previous layers?

Any help would be really appreciated :slight_smile:


Most likely your previous model used some nn.Sequential containers, which can be indexed to get the corresponding layer.
If EfficientNet doesn’t use nn.Seuqential modules, you would have to directly access the desired modules via:


where layer would be the name of the layer you would like to access.
To get the layer names you could either print(model) or iterate all modules using model.named_modules().