Analysis Tools
This section discusses methods to analyze trained models. The system automatically generates training graphs and stores model checkpoints for analysis.
Loss Graphs and Win-Rate Visualization
Understanding the Training Metrics
Three main graphs are recorded for every model:
1. V-Loss Graph (Value Loss)
- Tracks the loss for value prediction (win probability)
- Lower values indicate better position evaluation
- Should decrease over iterations as model improves
2. P-Loss Graph (Policy Loss)
- Tracks the loss for move prediction
- Measures how well the model predicts expert moves
- Convergence indicates consistent move selection
3. Win-Rate Graph
- Shows proportion of wins against previous best model
- Blue line at 0.54 (54%) indicates acceptance threshold
- New model accepted only if win rate exceeds threshold
Neural Network Architecture
The neural network processes Go positions with:
Input: Board state encoded as multi-channel tensor
- Multiple planes representing current and historical positions
- Encodes stone positions, turn information, and game history
Output:
- Policy (P): Probability distribution over all legal moves
- Includes pass move option
- Softmax normalized (sums to 1)
- Value (V): Position evaluation score
- Range: [-1, 1]
- Represents expected game outcome from current position
Theoretical Fine-Tuning
Configuration Parameters
Key parameters in config.yaml
for model tuning:
# Network Architecture
num_channels: 128 # Width of convolutional layers
network_type: RES # ResNet architecture
# Training Hyperparameters
learning_rate: 0.0001 # Base learning rate
batch_size: 2048 # Training batch size
epochs: 10 # Epochs per iteration
# MCTS Parameters
num_full_search_sims: 500 # MCTS simulations per move
c_puct: 1.0 # UCT exploration constant
temperature_threshold: 4 # Moves before deterministic play
Expected Outcomes
Network Tuning:
num_channels
: Increase for better pattern recognitionnetwork_type
: RES (ResNet) or CNN options available- Trade-off: Larger networks require more compute
MCTS Tuning:
num_full_search_sims
: More simulations = stronger playc_puct
: Higher values encourage explorationtemperature_threshold
: Controls move randomness in early game
Model Explainability with Grad-CAM
Understanding Neural Network Decisions
Grad-CAM (Gradient-weighted Class Activation Mapping) visualizes which board regions influence the neural network’s decisions.
How Grad-CAM Works
- Forward Pass: Input board state through network
- Backward Pass: Calculate gradients for target move
- Heat Map: Highlight important board regions
- Interpretation: See what the model “focuses on”
Application to Go
For a given board position:
- Bright regions: Critical for move decision
- Dark regions: Less influential areas
- Pattern recognition: Identifies learned Go concepts
Using Grad-CAM Analysis
Access the Grad-CAM implementation:
- Repository: https://github.com/ductoanng/AZ-Go-Grad-CAM
- Jupyter Notebook:
AZ-Go-Grad-CAM.ipynb
Steps for analysis:
- Load trained model checkpoint
- Select interesting game positions
- Run Grad-CAM visualization
- Interpret attention patterns
Example Insights
Common patterns revealed by Grad-CAM:
- Corner focus: Early game emphasis on corners
- Group safety: Attention to endangered stones
- Territory boundaries: Recognition of territorial lines
- Ko situations: Heightened attention during ko fights
Performance Metrics
Training Progress Indicators
Monitor these metrics across iterations:
- Loss Convergence
- Both losses should decrease
- Plateaus indicate learning limits
- Win Rate Trends
- Gradual improvement expected
- Sudden drops may indicate overfitting
- Game Length Distribution
- Shorter games → More decisive play
- Very short games → Possible issues
Model Evaluation Methods
- Arena Win Rates: Track improvement across iterations
- Self-Play Quality: Review generated training games
- Manual Testing: Play against model via GTP interface
- KataGo Comparison: Use KataGo integration for analysis
Practical Analysis Workflow
Accessing Training Metrics
- View Training Graphs: Check
logs/graphs/
for PNG files- Graphs are saved with timestamps
- Updated after each training iteration
- Load Model Checkpoints: Use saved models in
logs/checkpoints/
best.pth.tar
: Current best modelcheckpoint_X.pth.tar
: Specific iterations
- Review Game Records: Analyze SGF files in
logs/arena_game_history/
- Contains games from arena evaluation
- Can be opened with any SGF viewer
Using the GTP Interface
Test models interactively:
# Launch GTP engine with trained model
python gtp/engine.py
This allows:
- Playing against the model
- Analyzing specific positions
- Testing model responses
Next Steps
- Training Guide - Optimize training parameters
- Usage Guide - Use analysis tools effectively