MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / Model

Class Model

examples/ResNet/imagenet-resnet.py:21–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21class Model(ImageNetModel):
22 def __init__(self, depth, mode='resnet'):
23 self.mode = mode
24 basicblock = getattr(resnet_model, mode + '_basicblock', None)
25 bottleneck = getattr(resnet_model, mode + '_bottleneck', None)
26 self.num_blocks, self.block_func = {
27 18: ([2, 2, 2, 2], basicblock),
28 34: ([3, 4, 6, 3], basicblock),
29 50: ([3, 4, 6, 3], bottleneck),
30 101: ([3, 4, 23, 3], bottleneck),
31 152: ([3, 8, 36, 3], bottleneck)
32 }[depth]
33 assert self.block_func is not None, \
34 "(mode={}, depth={}) not implemented!".format(mode, depth)
35
36 def get_logits(self, image):
37 with argscope([Conv2D, MaxPooling, GlobalAvgPooling, BatchNorm], data_format=self.data_format):
38 return resnet_backbone(
39 image, self.num_blocks,
40 preact_group if self.mode == 'preact' else resnet_group, self.block_func)
41
42
43def get_config(model):

Callers 1

imagenet-resnet.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…