-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathAlexNet.py
More file actions
57 lines (37 loc) · 1.44 KB
/
AlexNet.py
File metadata and controls
57 lines (37 loc) · 1.44 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import torch.nn as nn
import torchvision.models as models
model_urls = {
'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
}
class LocalizerAlexNet(nn.Module):
def __init__(self, num_classes=20):
super(LocalizerAlexNet, self).__init__()
# TODO (Q1.1): Define model
def forward(self, x):
# TODO (Q1.1): Define forward pass
return x
class LocalizerAlexNetRobust(nn.Module):
def __init__(self, num_classes=20):
super(LocalizerAlexNetRobust, self).__init__()
# TODO (Q1.7): Define model
def forward(self, x):
# TODO (Q1.7): Define forward pass
return x
def localizer_alexnet(pretrained=False, **kwargs):
r"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = LocalizerAlexNet(**kwargs)
# TODO (Q1.3): Initialize weights based on whether it is pretrained or not
return model
def localizer_alexnet_robust(pretrained=False, **kwargs):
r"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = LocalizerAlexNetRobust(**kwargs)
# TODO (Q1.7): Initialize weights based on whether it is pretrained or not
return model