MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / __init__

Method __init__

timm/models/xception_aligned.py:120–155  ·  view source on GitHub ↗
(self, block_cfg, num_classes=1000, in_chans=3, output_stride=32,
                 act_layer=nn.ReLU, norm_layer=nn.BatchNorm2d, drop_rate=0., global_pool='avg')

Source from the content-addressed store, hash-verified

118 """
119
120 def __init__(self, block_cfg, num_classes=1000, in_chans=3, output_stride=32,
121 act_layer=nn.ReLU, norm_layer=nn.BatchNorm2d, drop_rate=0., global_pool='avg'):
122 super(XceptionAligned, self).__init__()
123 self.num_classes = num_classes
124 self.drop_rate = drop_rate
125 assert output_stride in (8, 16, 32)
126
127 layer_args = dict(act_layer=act_layer, norm_layer=norm_layer)
128 self.stem = nn.Sequential(*[
129 ConvBnAct(in_chans, 32, kernel_size=3, stride=2, **layer_args),
130 ConvBnAct(32, 64, kernel_size=3, stride=1, **layer_args)
131 ])
132
133 curr_dilation = 1
134 curr_stride = 2
135 self.feature_info = []
136 self.blocks = nn.Sequential()
137 for i, b in enumerate(block_cfg):
138 b['dilation'] = curr_dilation
139 if b['stride'] > 1:
140 self.feature_info += [dict(
141 num_chs=to_3tuple(b['out_chs'])[-2], reduction=curr_stride, module=f'blocks.{i}.stack.act3')]
142 next_stride = curr_stride * b['stride']
143 if next_stride > output_stride:
144 curr_dilation *= b['stride']
145 b['stride'] = 1
146 else:
147 curr_stride = next_stride
148 self.blocks.add_module(str(i), XceptionModule(**b, **layer_args))
149 self.num_features = self.blocks[-1].out_channels
150
151 self.feature_info += [dict(
152 num_chs=self.num_features, reduction=curr_stride, module='blocks.' + str(len(self.blocks) - 1))]
153
154 self.head = ClassifierHead(
155 in_chs=self.num_features, num_classes=num_classes, pool_type=global_pool, drop_rate=drop_rate)
156
157 def get_classifier(self):
158 return self.head.fc

Callers

nothing calls this directly

Calls 4

XceptionModuleClass · 0.85
ClassifierHeadClass · 0.85
ConvBnActClass · 0.50
__init__Method · 0.45

Tested by

no test coverage detected