Replace conv trunk with a configurable residual tower#14
Merged
Conversation
Swap the two-layer conv trunk for a stem plus N residual blocks (skip connections, no normalization), with `channels` and `num_res_blocks` constructor knobs (defaults 64 / 4). Skip connections keep gradients flowing through deeper trunks; BatchNorm is omitted so the block is safe for any batch size, including the size-1 final training batch. forward/predict/predict_batch signatures are unchanged, so MCTS and training are untouched. Adds tests for configurability, the stem-only (zero-block) case, skip-path gradient flow, and config validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Swap
AlphaZeroNet's two-layer conv trunk for a stem + N residual blocks, withchannelsandnum_res_blocksconstructor knobs (defaults 64 / 4). This is the trunk architecture real AlphaZero uses (minus normalization, see below) and lets the network scale depth/width per game.Motivation
Residual connections let gradients flow straight through a deep trunk, enabling more representational capacity than the current 2-conv stack without vanishing-gradient problems. Depth/width are now tunable per game rather than hardcoded.
Design notes
Conv→ReLU→Conv + skip → ReLU. BN can be added later alongsidedrop_lastintrain.py.forward/predict/predict_batchare identical, so MCTS and training need no changes; only the trunk internals differ.Testing
pytest tests/test_network.py tests/test_train.py→ 18 passed.num_res_blocks=0), skip-path gradient flow, and config validation.Review focus
num_res_blocks=4/channels=64— reasonable for small boards, or too heavy?