How to add new Relu & fc layer in pretrained Resnet-152 model

Hy! I have loaded Resnet-152 pre-trained model, and modified the out features of the fc layer through following model.

Now i want to apply relu on the modified fc layer, and then add a new fc layer which take out_features of previous fc layer, and out_feature = 10, like this:


Any Help?

You could assign an nn.Sequential container to model.fc instead of a single linear layer via:

model.fc = nn.Sequential(
    nn.Linear(num_ftrs, 1024),
    nn.Linear(1024, 10)

Thanks Dear @ptrblck ! It worked :slight_smile: