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

Method __init__

timm/models/efficientnet.py:503–534  ·  view source on GitHub ↗
(self, block_args, out_indices=(0, 1, 2, 3, 4), feature_location='bottleneck', in_chans=3,
                 stem_size=32, fix_stem=False, output_stride=32, pad_type='', round_chs_fn=round_channels,
                 act_layer=None, norm_layer=None, se_layer=None, drop_rate=0., drop_path_rate=0.)

Source from the content-addressed store, hash-verified

501 """
502
503 def __init__(self, block_args, out_indices=(0, 1, 2, 3, 4), feature_location='bottleneck', in_chans=3,
504 stem_size=32, fix_stem=False, output_stride=32, pad_type='', round_chs_fn=round_channels,
505 act_layer=None, norm_layer=None, se_layer=None, drop_rate=0., drop_path_rate=0.):
506 super(EfficientNetFeatures, self).__init__()
507 act_layer = act_layer or nn.ReLU
508 norm_layer = norm_layer or nn.BatchNorm2d
509 se_layer = se_layer or SqueezeExcite
510 self.drop_rate = drop_rate
511
512 # Stem
513 if not fix_stem:
514 stem_size = round_chs_fn(stem_size)
515 self.conv_stem = create_conv2d(in_chans, stem_size, 3, stride=2, padding=pad_type)
516 self.bn1 = norm_layer(stem_size)
517 self.act1 = act_layer(inplace=True)
518
519 # Middle stages (IR/ER/DS Blocks)
520 builder = EfficientNetBuilder(
521 output_stride=output_stride, pad_type=pad_type, round_chs_fn=round_chs_fn,
522 act_layer=act_layer, norm_layer=norm_layer, se_layer=se_layer, drop_path_rate=drop_path_rate,
523 feature_location=feature_location)
524 self.blocks = nn.Sequential(*builder(stem_size, block_args))
525 self.feature_info = FeatureInfo(builder.features, out_indices)
526 self._stage_out_idx = {v['stage']: i for i, v in enumerate(self.feature_info) if i in out_indices}
527
528 efficientnet_init_weights(self)
529
530 # Register feature extraction hooks with FeatureHooks helper
531 self.feature_hooks = None
532 if feature_location != 'bottleneck':
533 hooks = self.feature_info.get_dicts(keys=('module', 'hook_type'))
534 self.feature_hooks = FeatureHooks(hooks, self.named_modules())
535
536 def forward(self, x) -> List[torch.Tensor]:
537 x = self.conv_stem(x)

Callers

nothing calls this directly

Calls 7

create_conv2dFunction · 0.90
EfficientNetBuilderClass · 0.85
FeatureInfoClass · 0.85
FeatureHooksClass · 0.85
get_dictsMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected