MCPcopy Create free account
hub / github.com/CausalLearning/robust-unlearnable-examples / VGG

Class VGG

models/vgg.py:16–45  ·  view source on GitHub ↗

VGG model

Source from the content-addressed store, hash-verified

14
15
16class VGG(nn.Module):
17 ''' VGG model '''
18 def __init__(self, features, out_channels):
19 super(VGG, self).__init__()
20 self.features = features
21 self.avgpool = nn.AdaptiveAvgPool2d((1,1))
22 self.classifier = nn.Sequential(
23 nn.Dropout(),
24 nn.Linear(512, 512),
25 nn.ReLU(True),
26 nn.Dropout(),
27 nn.Linear(512, 512),
28 nn.ReLU(True),
29 nn.Linear(512, out_channels),
30 )
31
32 ''' Initialize weights '''
33 for m in self.modules():
34 if isinstance(m, nn.Conv2d):
35 n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
36 m.weight.data.normal_(0, math.sqrt(2. / n))
37 m.bias.data.zero_()
38
39
40 def forward(self, x):
41 x = self.features(x)
42 x = self.avgpool(x)
43 x = torch.flatten(x, 1)
44 x = self.classifier(x)
45 return x
46
47
48def make_layers(cfg, in_dims=3, batch_norm=False):

Callers 3

vgg11_bnFunction · 0.85
vgg16_bnFunction · 0.85
vgg19_bnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected