MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / __init__

Method __init__

astroclip/modules.py:223–241  ·  view source on GitHub ↗
(
        self,
        embedding_dim: int,
        num_heads: int,
        causal: bool,
        dropout: float,
        bias: bool = True,
        mlp_expansion: int = 4,
    )

Source from the content-addressed store, hash-verified

221 """
222
223 def __init__(
224 self,
225 embedding_dim: int,
226 num_heads: int,
227 causal: bool,
228 dropout: float,
229 bias: bool = True,
230 mlp_expansion: int = 4,
231 ):
232 super().__init__()
233
234 self.layernorm1 = LayerNorm(embedding_dim, bias=bias)
235 self.attention = SelfAttention(
236 embedding_dim, num_heads, bias=bias, dropout=dropout, causal=causal
237 )
238 self.layernorm2 = LayerNorm(embedding_dim, bias=bias)
239
240 hidden_dim = mlp_expansion * embedding_dim
241 self.mlp = MLP(embedding_dim, hidden_dim, nn.GELU(), dropout=dropout, bias=bias)
242
243 def forward(self, x):
244 x = x + self.attention(self.layernorm1(x))

Callers

nothing calls this directly

Calls 4

LayerNormClass · 0.85
SelfAttentionClass · 0.85
MLPClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected