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

Method post_encode

models/fact/Network.py:95–117  ·  view source on GitHub ↗
(self,x)

Source from the content-addressed store, hash-verified

93
94
95 def post_encode(self,x):
96 if self.args.dataset in ['cifar100','manyshotcifar']:
97
98 x = self.encoder.layer3(x)
99 x = F.adaptive_avg_pool2d(x, 1)
100 x = x.squeeze(-1).squeeze(-1)
101
102 elif self.args.dataset in ['mini_imagenet','manyshotmini','cub200']:
103
104 x = self.encoder.layer3(x)
105 x = self.encoder.layer4(x)
106 x = F.adaptive_avg_pool2d(x, 1)
107 x = x.squeeze(-1).squeeze(-1)
108
109 if 'cos' in self.mode:
110 x = F.linear(F.normalize(x, p=2, dim=-1), F.normalize(self.fc.weight, p=2, dim=-1))
111 x = self.args.temperature * x
112
113 elif 'dot' in self.mode:
114 x = self.fc(x)
115 x = self.args.temperature * x
116
117 return x
118
119 def forward(self, input):
120 if self.mode != 'encoder':

Callers 1

base_trainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected