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

Method __init__

segmentation/backbones/vit_SelfPatch.py:148–256  ·  view source on GitHub ↗
(self,
                 img_size=224,
                 patch_size=16,
                 in_channels=3,
                 embed_dims=768,
                 num_layers=12,
                 num_heads=12,
                 mlp_ratio=4,
                 out_indices=-1,
                 qkv_bias=True,
                 drop_rate=0.,
                 attn_drop_rate=0.,
                 drop_path_rate=0.,
                 with_cls_token=True,
                 output_cls_token=False,
                 norm_cfg=dict(type='LN'),
                 act_cfg=dict(type='GELU'),
                 patch_norm=False,
                 final_norm=False,
                 interpolate_mode='bicubic',
                 num_fcs=2,
                 norm_eval=False,
                 with_cp=False,
                 pretrained=None,
                 init_cfg=None)

Source from the content-addressed store, hash-verified

146 """
147
148 def __init__(self,
149 img_size=224,
150 patch_size=16,
151 in_channels=3,
152 embed_dims=768,
153 num_layers=12,
154 num_heads=12,
155 mlp_ratio=4,
156 out_indices=-1,
157 qkv_bias=True,
158 drop_rate=0.,
159 attn_drop_rate=0.,
160 drop_path_rate=0.,
161 with_cls_token=True,
162 output_cls_token=False,
163 norm_cfg=dict(type='LN'),
164 act_cfg=dict(type='GELU'),
165 patch_norm=False,
166 final_norm=False,
167 interpolate_mode='bicubic',
168 num_fcs=2,
169 norm_eval=False,
170 with_cp=False,
171 pretrained=None,
172 init_cfg=None):
173 super(SelfPatch_ViT, self).__init__()
174
175 if isinstance(img_size, int):
176 img_size = to_2tuple(img_size)
177 elif isinstance(img_size, tuple):
178 if len(img_size) == 1:
179 img_size = to_2tuple(img_size[0])
180 assert len(img_size) == 2, \
181 f'The size of image should have length 1 or 2, ' \
182 f'but got {len(img_size)}'
183
184 if output_cls_token:
185 assert with_cls_token is True, f'with_cls_token must be True if' \
186 f'set output_cls_token to True, but got {with_cls_token}'
187
188 if isinstance(pretrained, str) or pretrained is None:
189 warnings.warn('DeprecationWarning: pretrained is a deprecated, '
190 'please use "init_cfg" instead')
191 else:
192 raise TypeError('pretrained must be a str or None')
193
194 self.img_size = img_size
195 self.patch_size = patch_size
196 self.interpolate_mode = interpolate_mode
197 self.norm_eval = norm_eval
198 self.with_cp = with_cp
199 self.pretrained = pretrained
200 self.init_cfg = init_cfg
201
202 self.patch_embed = PatchEmbed(
203 in_channels=in_channels,
204 embed_dims=embed_dims,
205 conv_type='Conv2d',

Callers 1

__init__Method · 0.45

Calls 2

PatchEmbedClass · 0.50

Tested by

no test coverage detected