MCPcopy Create free account
hub / github.com/pytorch/pytorch / create

Method create

caffe2/python/models/shufflenet.py:47–79  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 self.bn_epsilon = bn_epsilon
46
47 def create(self):
48 in_channels = self.output_channels[0]
49
50 self.prev_blob = brew.conv(self.model, self.prev_blob, 'stage1_conv',
51 self.num_input_channels, in_channels,
52 weight_init=("MSRAFill", {}),
53 kernel=3, stride=2)
54 self.prev_blob = brew.max_pool(self.model, self.prev_blob,
55 'stage1_pool', kernel=3, stride=2)
56
57 # adds stage#{2,3,4}; see table 5 of the ShufflenetV2 paper.
58 for idx, (out_channels, n_repeats) in enumerate(zip(
59 self.output_channels[1:4], self.stage_repeats
60 )):
61 prefix = 'stage{}_stride{}'.format(idx + 2, 2)
62 self.add_spatial_ds_unit(prefix, in_channels, out_channels)
63 in_channels = out_channels
64 for i in range(n_repeats):
65 prefix = 'stage{}_stride{}_repeat{}'.format(
66 idx + 2, 1, i + 1
67 )
68 self.add_basic_unit(prefix, in_channels)
69
70 self.last_conv = brew.conv(self.model, self.prev_blob, 'conv5',
71 in_channels, self.output_channels[4],
72 kernel=1)
73 self.avg_pool = self.model.AveragePool(self.last_conv, 'avg_pool',
74 kernel=7)
75 self.last_out = brew.fc(self.model,
76 self.avg_pool,
77 'last_out_L{}'.format(self.num_labels),
78 self.output_channels[4],
79 self.num_labels)
80
81 # spatial down sampling unit with stride=2
82 def add_spatial_ds_unit(self, prefix, in_channels, out_channels, stride=2):

Callers 1

create_shufflenetFunction · 0.95

Calls 6

add_spatial_ds_unitMethod · 0.95
add_basic_unitMethod · 0.95
AveragePoolMethod · 0.80
rangeFunction · 0.50
convMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected