MCPcopy Create free account
hub / github.com/Closed11/Unsupervised-Image-Classification / forward

Method forward

UIC/models/resnet50.py:248–285  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

246 return nn.Sequential(*layers)
247
248 def forward(self, x):
249 if not self.linear_eval:
250 with torch.no_grad():
251 if self.gblur:
252 x = self.gblur(x)
253 x = self.conv1(x)
254 x = self.bn1(x)
255 x = self.relu(x)
256 x = self.maxpool(x)
257
258 x = self.layer1(x)
259 x = self.layer2(x)
260 x = self.layer3(x)
261 x = self.layer4(x)
262
263 x = self.avgpool(x)
264 if self.extra_mlp:
265 x = self.head(x)
266 x = torch.flatten(x, 1)
267 x = self.fc(x)
268 else:
269 with torch.no_grad():
270 x = self.conv1(x)
271 x = self.bn1(x)
272 x = self.relu(x)
273 x = self.maxpool(x)
274 x = self.layer1(x)
275 x = self.layer2(x)
276 x = self.layer3(x)
277 x = self.layer4(x)
278 x = self.avgpool(x)
279 if self.extra_mlp:
280 x = self.head(x)
281 x = torch.flatten(x, 1)
282 x = x.detach()
283 x = self.linear(x)
284
285 return x
286
287def _resnet(block, layers, out=1000, dim=3, **kwargs):
288 model = ResNet(block, layers, num_classes=out, dim=dim, **kwargs)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected