Class MultiHeadSelfAttention

java.lang.Object
io.github.kirstenali.deepj.layers.transformer.attention.MultiHeadSelfAttention
All Implemented Interfaces:
Layer, Trainable
Direct Known Subclasses:
RoPEMultiHeadSelfAttention

public class MultiHeadSelfAttention extends Object implements Layer
Multi-head causal self-attention for a single sequence (no batch dimension). Input/Output shape: [seqLen x dModel]
  • Field Details

    • nHeads

      protected final int nHeads
      Exposed to subclasses that need head count for custom Q/K transforms (e.g. RoPE).
    • headDim

      protected final int headDim
      Exposed to subclasses that need per-head dimension for custom Q/K transforms.
  • Constructor Details

    • MultiHeadSelfAttention

      public MultiHeadSelfAttention(int dModel, int nHeads, boolean causalMask, Random rnd)
  • Method Details