MCPcopy Create free account
hub / github.com/geekcomputers/Python / __init__

Method __init__

ML/src/python/neuralforge/nn/attention.py:101–109  ·  view source on GitHub ↗
(self, embed_dim, num_heads, mlp_ratio=4.0, dropout=0.1, drop_path=0.0)

Source from the content-addressed store, hash-verified

99
100class TransformerBlock(nn.Module):
101 def __init__(self, embed_dim, num_heads, mlp_ratio=4.0, dropout=0.1, drop_path=0.0):
102 super().__init__()
103 self.norm1 = nn.LayerNorm(embed_dim)
104 self.attn = MultiHeadAttention(embed_dim, num_heads, dropout)
105 self.norm2 = nn.LayerNorm(embed_dim)
106 self.mlp = FeedForward(embed_dim, int(embed_dim * mlp_ratio), dropout)
107
108 from .modules import DropPath
109 self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
110
111 def forward(self, x, mask=None):
112 x = x + self.drop_path(self.attn(self.norm1(x), mask))

Callers

nothing calls this directly

Calls 4

MultiHeadAttentionClass · 0.85
FeedForwardClass · 0.85
DropPathClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected