So, I’ve been trying to modify http://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html 142 to work with DenseNet instead of ResNet, but I can’t seem to figure out what to change the fc layer to.
This is what I currently have:
model_ft = models.densenet169(pretrained=True)
num_features = model_ft.fc.in_features
model_ft.fc = nn.Linear(num_features, len(CLASS_NAMES))

but running the code gives me this error:
Traceback (most recent call last):
  File "pytorch_densenet.py", line 154, in <module>
    num_features = model_ft.fc.in_features
  File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 398, in __getattr__
    type(self).__name__, name))
AttributeError: 'DenseNet' object has no attribute 'fc'

So, uh… How do I change the last layer of DenseNet to work with Transfer Learning?
Thanks a lot.