Repository navigation
selfAttention backward
GitHub Action edited this page Jul 9, 2026
·
1 revision
std::pair<utility::matrix, std::vector<utility::matrix>> backward(utility::matrix dZ)Returns the gradient to be passed back (backward(dZ).first) and a vector of the gradients for each self attention matrix (backward(dZ.second).
Returns a std::pair<utility::matrix, std::vector<utility::matrix>>
| Parameter | Type | Use | Optional |
|---|---|---|---|
dZ |
utility::matrix |
Gradient matrix | ❌ |
// Calling the backward() function
selfAttention a( 128);
utility::matrix dZ; // Pass a gradient from undoing the unembed and softmax layer at the very end.
dZ = a.backward(dZ).first;- AIUsage
- Block
- Embedder
- Introduction
- Layer
- Model
- NeuralNetwork
- PositionalEncoding
- SelfAttention
- Tokenizer
- Utility