Class MultiHeadSelfAttention
java.lang.Object
io.github.kirstenali.deepj.layers.transformer.attention.MultiHeadSelfAttention
- Direct Known Subclasses:
RoPEMultiHeadSelfAttention
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMultiHeadSelfAttention(int dModel, int nHeads, boolean causalMask, Random rnd) MultiHeadSelfAttention(int dModel, int nHeads, boolean causalMask, Random rnd, ParameterFactory parameters) -
Method Summary
Modifier and TypeMethodDescriptionforward(Tensor input, InferenceContext context) booleanprotected TensortransformQueryKey(Tensor heads, int seqLen) protected TensortransformQueryKey(Tensor heads, int length, int offset) protected TensortransformQueryKey(Tensor heads, int length, InferenceContext context)
-
Field Details
-
nHeads
protected final int nHeads -
headDim
protected final int headDim
-
-
Constructor Details
-
MultiHeadSelfAttention
-
MultiHeadSelfAttention
public MultiHeadSelfAttention(int dModel, int nHeads, boolean causalMask, Random rnd, ParameterFactory parameters)
-
-
Method Details
-
forward
-
transformQueryKey
-
transformQueryKey
-
transformQueryKey
-
supportsIncrementalInference
public boolean supportsIncrementalInference()- Specified by:
supportsIncrementalInferencein interfaceLayer
-
forward
-
parameters
- Specified by:
parametersin interfaceTrainable
-