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

Method __init__

timm/models/coat.py:233–264  ·  view source on GitHub ↗
(self, dims, num_heads, mlp_ratios=[], qkv_bias=False, drop=0., attn_drop=0.,
                 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, shared_crpes=None)

Source from the content-addressed store, hash-verified

231class ParallelBlock(nn.Module):
232 """ Parallel block class. """
233 def __init__(self, dims, num_heads, mlp_ratios=[], qkv_bias=False, drop=0., attn_drop=0.,
234 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, shared_crpes=None):
235 super().__init__()
236
237 # Conv-Attention.
238 self.norm12 = norm_layer(dims[1])
239 self.norm13 = norm_layer(dims[2])
240 self.norm14 = norm_layer(dims[3])
241 self.factoratt_crpe2 = FactorAtt_ConvRelPosEnc(
242 dims[1], num_heads=num_heads, qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop,
243 shared_crpe=shared_crpes[1]
244 )
245 self.factoratt_crpe3 = FactorAtt_ConvRelPosEnc(
246 dims[2], num_heads=num_heads, qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop,
247 shared_crpe=shared_crpes[2]
248 )
249 self.factoratt_crpe4 = FactorAtt_ConvRelPosEnc(
250 dims[3], num_heads=num_heads, qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop,
251 shared_crpe=shared_crpes[3]
252 )
253 self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
254
255 # MLP.
256 self.norm22 = norm_layer(dims[1])
257 self.norm23 = norm_layer(dims[2])
258 self.norm24 = norm_layer(dims[3])
259 # In parallel block, we assume dimensions are the same and share the linear transformation.
260 assert dims[1] == dims[2] == dims[3]
261 assert mlp_ratios[1] == mlp_ratios[2] == mlp_ratios[3]
262 mlp_hidden_dim = int(dims[1] * mlp_ratios[1])
263 self.mlp2 = self.mlp3 = self.mlp4 = Mlp(
264 in_features=dims[1], hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
265
266 def upsample(self, x, factor: float, size: Tuple[int, int]):
267 """ Feature map up-sampling. """

Callers

nothing calls this directly

Calls 4

DropPathClass · 0.85
MlpClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected