MCPcopy Create free account
hub / github.com/Tang1705/Baidu-Rot-Validate / __init__

Method __init__

VisionTransformer.py:103–113  ·  view source on GitHub ↗
(self, in_dim, mlp_dim, num_heads, dropout_rate=0.1, attn_dropout_rate=0.1)

Source from the content-addressed store, hash-verified

101
102class EncoderBlock(nn.Module):
103 def __init__(self, in_dim, mlp_dim, num_heads, dropout_rate=0.1, attn_dropout_rate=0.1):
104 super(EncoderBlock, self).__init__()
105
106 self.norm1 = nn.LayerNorm(in_dim)
107 self.attn = SelfAttention(in_dim, heads=num_heads, dropout_rate=attn_dropout_rate)
108 if dropout_rate > 0:
109 self.dropout = nn.Dropout(dropout_rate)
110 else:
111 self.dropout = None
112 self.norm2 = nn.LayerNorm(in_dim)
113 self.mlp = MlpBlock(in_dim, mlp_dim, in_dim, dropout_rate)
114
115 def forward(self, x):
116 residual = x

Callers

nothing calls this directly

Calls 3

SelfAttentionClass · 0.85
MlpBlockClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected