Skip to content

Commit 1c780e8

Browse files
authored
Merge pull request #57 from kli-nlpr/patch-1
Update transfer_learning_tutorial.py
2 parents 905eaf0 + 185bef0 commit 1c780e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

beginner_source/transfer_learning_tutorial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ def optim_scheduler_ft(model, epoch, init_lr=0.001, lr_decay_epoch=7):
297297
param.requires_grad = False
298298

299299
# Parameters of newly constructed modules have requires_grad=True by default
300-
model.fc = nn.Linear(512, 100)
300+
num_ftrs = model.fc.in_features
301+
model.fc = nn.Linear(num_ftrs, 2)
301302

302303
if use_gpu:
303304
model = model.cuda()

0 commit comments

Comments
 (0)