MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / __init__

Method __init__

segmentation/backbones/unet.py:108–138  ·  view source on GitHub ↗
(self,
                 in_channels,
                 out_channels,
                 with_cp=False,
                 norm_cfg=dict(type='BN'),
                 act_cfg=dict(type='ReLU'),
                 *,
                 kernel_size=4,
                 scale_factor=2)

Source from the content-addressed store, hash-verified

106 """
107
108 def __init__(self,
109 in_channels,
110 out_channels,
111 with_cp=False,
112 norm_cfg=dict(type='BN'),
113 act_cfg=dict(type='ReLU'),
114 *,
115 kernel_size=4,
116 scale_factor=2):
117 super(DeconvModule, self).__init__()
118
119 assert (kernel_size - scale_factor >= 0) and\
120 (kernel_size - scale_factor) % 2 == 0,\
121 f'kernel_size should be greater than or equal to scale_factor '\
122 f'and (kernel_size - scale_factor) should be even numbers, '\
123 f'while the kernel size is {kernel_size} and scale_factor is '\
124 f'{scale_factor}.'
125
126 stride = scale_factor
127 padding = (kernel_size - scale_factor) // 2
128 self.with_cp = with_cp
129 deconv = nn.ConvTranspose2d(
130 in_channels,
131 out_channels,
132 kernel_size=kernel_size,
133 stride=stride,
134 padding=padding)
135
136 norm_name, norm = build_norm_layer(norm_cfg, out_channels)
137 activate = build_activation_layer(act_cfg)
138 self.deconv_upsamping = nn.Sequential(deconv, norm, activate)
139
140 def forward(self, x):
141 """Forward function."""

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected