MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / Bottleneck

Class Bottleneck

detrsmpl/models/backbones/resnet.py:97–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96
97class Bottleneck(BaseModule):
98 expansion = 4
99
100 def __init__(self,
101 inplanes,
102 planes,
103 stride=1,
104 dilation=1,
105 downsample=None,
106 style='pytorch',
107 with_cp=False,
108 conv_cfg=None,
109 norm_cfg=dict(type='BN'),
110 dcn=None,
111 plugins=None,
112 init_cfg=None):
113 """Bottleneck block for ResNet.
114
115 If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
116 it is "caffe", the stride-two layer is the first 1x1 conv layer.
117 """
118 super(Bottleneck, self).__init__(init_cfg)
119 assert style in ['pytorch', 'caffe']
120 assert dcn is None or isinstance(dcn, dict)
121 assert plugins is None or isinstance(plugins, list)
122 if plugins is not None:
123 allowed_position = ['after_conv1', 'after_conv2', 'after_conv3']
124 assert all(p['position'] in allowed_position for p in plugins)
125
126 self.inplanes = inplanes
127 self.planes = planes
128 self.stride = stride
129 self.dilation = dilation
130 self.style = style
131 self.with_cp = with_cp
132 self.conv_cfg = conv_cfg
133 self.norm_cfg = norm_cfg
134 self.dcn = dcn
135 self.with_dcn = dcn is not None
136 self.plugins = plugins
137 self.with_plugins = plugins is not None
138
139 if self.with_plugins:
140 # collect plugins for conv1/conv2/conv3
141 self.after_conv1_plugins = [
142 plugin['cfg'] for plugin in plugins
143 if plugin['position'] == 'after_conv1'
144 ]
145 self.after_conv2_plugins = [
146 plugin['cfg'] for plugin in plugins
147 if plugin['position'] == 'after_conv2'
148 ]
149 self.after_conv3_plugins = [
150 plugin['cfg'] for plugin in plugins
151 if plugin['position'] == 'after_conv3'
152 ]
153
154 if self.style == 'pytorch':

Callers 1

_make_conv_layerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected