Class GPTTransformerBlock
java.lang.Object
io.github.kirstenali.deepj.layers.transformer.blocks.GPTTransformerBlock
Pre-LN GPT-style Transformer block:
x = x + Attn( LayerNorm(x) ) x = x + MLP( LayerNorm(x) )
Composes LayerNorm1D, MultiHeadSelfAttention, and an FNN
(feed-forward network with a configurable activation — default: GELU).
-
Constructor Summary
ConstructorsConstructorDescriptionGPTTransformerBlock(int dModel, int nHeads, int dFF, Supplier<ActivationFunction> ffnActivationFactory, Random rnd) Full constructor.GPTTransformerBlock(int dModel, int nHeads, int dFF, Random rnd) Convenience constructor using GELU activation. -
Method Summary
-
Constructor Details
-
GPTTransformerBlock
Convenience constructor using GELU activation.- Parameters:
dModel- model dimensionnHeads- attention heads (must divide dModel)dFF- feed-forward inner dimensionrnd- random source for weight initialisation
-
GPTTransformerBlock
public GPTTransformerBlock(int dModel, int nHeads, int dFF, Supplier<ActivationFunction> ffnActivationFactory, Random rnd) Full constructor.- Parameters:
dModel- model dimensionnHeads- attention heads (must divide dModel)dFF- feed-forward inner dimensionffnActivationFactory- factory for the FFN hidden activation (e.g.GELU::new)rnd- random source for weight initialisation
-
-
Method Details
-
subLayers
Return the ordered sub-layers that own trainable parameters. -
forward
-
backward
-
parameters
- Specified by:
parametersin interfaceTrainable
-