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