MCPcopy
hub / github.com/alibaba/EasyCV / test_genet_withfc

Method test_genet_withfc

tests/test_models/backbones/test_genet.py:18–34  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

16 print(('Testing %s.%s' % (type(self).__name__, self._testMethodName)))
17
18 def test_genet_withfc(self):
19 for struct in ['normal', 'large']:
20 with torch.no_grad():
21 # input data
22 batch_size = random.randint(10, 30)
23 a = torch.rand(batch_size, 3, 224, 224).to('cuda')
24
25 num_classes = random.randint(10, 1000)
26 net = PlainNet(struct, num_classes=num_classes).to('cuda')
27 net.init_weights()
28 net.eval()
29
30 self.assertTrue(len(list(net(a)[-1].shape)) == 2)
31
32 self.assertTrue(net(a)[-1].size(1) == num_classes)
33
34 self.assertTrue(net(a)[-1].size(0) == batch_size)
35
36 def test_genet_withoutfc(self):
37 for struct in ['normal', 'large']:

Callers

nothing calls this directly

Calls 4

PlainNetClass · 0.90
toMethod · 0.45
init_weightsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected