-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
27 lines (23 loc) · 781 Bytes
/
model.py
File metadata and controls
27 lines (23 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from torch import nn
from torchvision import models
class Model(object):
"""docstring for Model"""
def __init__(self):
super(Model, self).__init__()
model = models.vgg19(pretrained=True)
model.classifier = nn.Sequential(
nn.Linear(25088, 4096),
nn.ReLU(),
nn.Dropout(0.5),
nn.Linear(4096, 4096),
nn.ReLU(),
nn.Dropout(0.5),
nn.Linear(4096, 102))
# this ensure to train the last conv layer & the classifier layer only
c = 37
for p in model.parameters():
p.requires_grad=False
c-=1
if c==15:
break
return model