Class GPTTransformerBlock

java.lang.Object
io.github.kirstenali.deepj.layers.transformer.blocks.GPTTransformerBlock
All Implemented Interfaces:
Layer, Trainable

public class GPTTransformerBlock extends Object
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 Details

    • GPTTransformerBlock

      public GPTTransformerBlock(int dModel, int nHeads, int dFF, Random rnd)
      Convenience constructor using GELU activation.
      Parameters:
      dModel - model dimension
      nHeads - attention heads (must divide dModel)
      dFF - feed-forward inner dimension
      rnd - random source for weight initialisation
    • GPTTransformerBlock

      public GPTTransformerBlock(int dModel, int nHeads, int dFF, Supplier<ActivationFunction> ffnActivationFactory, Random rnd)
      Full constructor.
      Parameters:
      dModel - model dimension
      nHeads - attention heads (must divide dModel)
      dFF - feed-forward inner dimension
      ffnActivationFactory - factory for the FFN hidden activation (e.g. GELU::new)
      rnd - random source for weight initialisation
  • Method Details