A tiny MLP (Linear(2,4) -> ReLU -> Linear(4,1)) trained on XOR – the canonical not-linearly-separable case, exactly representable by a small MLP, giving an unambiguous convergence target for Phase 1's "prove the training loop works" goal.
More...
#include <xor_training_example.hpp>
|
| | XorNetwork (DeviceBackend *backend) |
| | Constructs the network with fixed, non-zero initial weights.
|
| |
| Tensor | forward (const Tensor &input) |
| | Runs the network forward.
|
| |
| float | train_step (const Tensor &input, const Tensor &target, AdamOptimizer &optimizer, MetricsSink &sink, int step) |
| | Runs one training step: forward, loss, backward through every layer, one Adam update per layer's parameters, and logs the loss.
|
| |
| const Tensor & | linear1_weight () const |
| | Test/inspection accessor.
|
| |
| LinearModule & | linear1 () |
| | Mutable layer accessors – Population Based Training's own exploit step needs to read/write this network's live weights directly (to copy a top performer's weights onto a bottom performer mid-training, via each LinearModule's own parameters()), which no existing const-only accessor supports. Logged as a small necessary scope addition, found by campaign_exai_dl_library_evolutionary_deep_learning's Phase 4 Mission 0.
|
| |
| LinearModule & | linear2 () |
| |
A tiny MLP (Linear(2,4) -> ReLU -> Linear(4,1)) trained on XOR – the canonical not-linearly-separable case, exactly representable by a small MLP, giving an unambiguous convergence target for Phase 1's "prove the training loop works" goal.
- Note
- Modules are chained directly (no ComputationGraph/Autograd involvement) – see mission_training_loop.md's design rationale. Batch size 1 (operator decision) – trains on one example at a time, no batching added to any module.
-
Deterministic, hand-picked non-zero initial weights, NOT a general Xavier/He scheme. All-zero initialization was tried first during this mission's design and found to break symmetry completely: with W=0 everywhere, every layer's forward output is 0 regardless of input, and every gradient that depends on multiplying by a zero weight or a zero (pre-activation) ReLU input is itself zero – linear1's weights and linear2's weights never receive a gradient at all, only linear2's bias does. Non-zero initial weights are required to break this symmetry; a small, fixed, sign-varied initialization is sufficient for a network this tiny. A general initialization scheme (Xavier/He) remains deferred until a real dataset needs one.
◆ XorNetwork()
Constructs the network with fixed, non-zero initial weights.
- Parameters
-
| backend | Backend to compute through. Not owned; must outlive this network. |
◆ forward()
| Tensor pulsatrix::XorNetwork::forward |
( |
const Tensor & |
input | ) |
|
Runs the network forward.
- Parameters
-
- Returns
- Shape (1,).
◆ linear1()
Mutable layer accessors – Population Based Training's own exploit step needs to read/write this network's live weights directly (to copy a top performer's weights onto a bottom performer mid-training, via each LinearModule's own parameters()), which no existing const-only accessor supports. Logged as a small necessary scope addition, found by campaign_exai_dl_library_evolutionary_deep_learning's Phase 4 Mission 0.
◆ linear1_weight()
| const Tensor & pulsatrix::XorNetwork::linear1_weight |
( |
| ) |
const |
|
inline |
Test/inspection accessor.
◆ linear2()
◆ train_step()
Runs one training step: forward, loss, backward through every layer, one Adam update per layer's parameters, and logs the loss.
- Parameters
-
| input | Shape (2,). |
| target | Shape (1,). |
| optimizer | Optimizer to update this network's parameters with. |
| sink | Where the loss value is logged (tag "loss"). |
| step | Training step number, passed through to sink. |
- Returns
- The loss value for this example, before the update.
The documentation for this class was generated from the following file: