MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / __init__

Method __init__

CV/SMILE/backbones/vit.py:260–290  ·  view source on GitHub ↗
(self,
                 embed_dim,
                 num_heads,
                 depth,
                 attn_head_size=None,
                 qkv_bias=True,
                 mlp_ratio=4.0,
                 dropout=0.,
                 attention_dropout=0.,
                 droppath=0.)

Source from the content-addressed store, hash-verified

258 encoder_norm: nn.LayerNorm which is applied after last encoder layer
259 """
260 def __init__(self,
261 embed_dim,
262 num_heads,
263 depth,
264 attn_head_size=None,
265 qkv_bias=True,
266 mlp_ratio=4.0,
267 dropout=0.,
268 attention_dropout=0.,
269 droppath=0.):
270 super().__init__()
271 # stochatic depth decay
272 depth_decay = [x.item() for x in paddle.linspace(0, droppath, depth)]
273
274 layer_list = []
275 for i in range(depth):
276 layer_list.append(TransformerLayer(embed_dim,
277 num_heads,
278 attn_head_size,
279 qkv_bias,
280 mlp_ratio,
281 dropout,
282 attention_dropout,
283 depth_decay[i]))
284 self.layers = nn.LayerList(layer_list)
285
286 w_attr_1, b_attr_1 = self._init_weights()
287 self.encoder_norm = nn.LayerNorm(embed_dim,
288 weight_attr=w_attr_1,
289 bias_attr=b_attr_1,
290 epsilon=1e-6)
291
292 def _init_weights(self):
293 weight_attr = paddle.ParamAttr(initializer=nn.initializer.Constant(1.0))

Callers

nothing calls this directly

Calls 4

_init_weightsMethod · 0.95
TransformerLayerClass · 0.85
__init__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected