MCPcopy Create free account
hub / github.com/LAMDA-CL/CVPR22-Fact / __init__

Method __init__

models/base/Network.py:12–29  ·  view source on GitHub ↗
(self, args, mode=None)

Source from the content-addressed store, hash-verified

10class MYNET(nn.Module):
11
12 def __init__(self, args, mode=None):
13 super().__init__()
14
15 self.mode = mode
16 self.args = args
17 # self.num_features = 512
18 if self.args.dataset in ['cifar100','manyshotcifar']:
19 self.encoder = resnet20()
20 self.num_features = 64
21 if self.args.dataset in ['mini_imagenet','manyshotmini','imagenet100','imagenet1000', 'mini_imagenet_withpath']:
22 self.encoder = resnet18(False, args) # pretrained=False
23 self.num_features = 512
24 if self.args.dataset in ['cub200','manyshotcub']:
25 self.encoder = resnet18(True, args) # pretrained=True follow TOPIC, models for cub is imagenet pre-trained. https://github.com/xyutao/fscil/issues/11#issuecomment-687548790
26 self.num_features = 512
27 self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
28
29 self.fc = nn.Linear(self.num_features, self.args.num_classes, bias=False)
30
31 def forward_metric(self, x):
32 x = self.encode(x)

Callers

nothing calls this directly

Calls 2

resnet20Function · 0.85
resnet18Function · 0.85

Tested by

no test coverage detected