diff options
| author | Dylan <boss@tehbox.org> | 2026-11-08 17:32:09 +1300 |
|---|---|---|
| committer | Dylan <boss@tehbox.org> | 2026-11-08 17:32:09 +1300 |
| commit | 312318ad6548f65cc6af118c24811dfd40280b27 (patch) | |
| tree | 0a2bb29cf2f3a6aa83d43ab076d3a0b263bbf6a0 /src/main.rs | |
| parent | 94f3df190a91898eb344b9214a57eb31792bcb1c (diff) | |
| download | tigers-and-sheep-312318ad6548f65cc6af118c24811dfd40280b27.tar.gz tigers-and-sheep-312318ad6548f65cc6af118c24811dfd40280b27.zip | |
feat: Resume training from any weights; balance training by outcome
- train --from <weights> starts from any saved network; without it,
training still carries on from the out dir's newest generation
- Each epoch takes as many positions from sheep-win games as from
tiger-win games (Config::balance_outcomes, on by default)
- Training output shows the error on tiger-win and sheep-win positions
separately, before and after training
- Fix a broken sentence in CLAUDE.md's cache description
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 8f6968d..1404a9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,14 @@ mod neural_player; mod train; fn main() -> std::io::Result<()> { - let args: Vec<String> = std::env::args().collect(); + let mut args: Vec<String> = std::env::args().collect(); + // `--from <weights>` can go anywhere after `train` + let from = args.iter().position(|a| a == "--from").map(|i| + { + let path = args.get(i + 1).cloned().expect("usage: --from <weights file>"); + args.drain(i..=i + 1); + path + }); let arg = |i: usize| args.get(i).map(String::as_str); let number = |i: usize, default: usize| arg(i).map_or(default, |n| n.parse().expect("expected a number")); match arg(1) @@ -29,7 +36,8 @@ fn main() -> std::io::Result<()> { bench::run(number(2, 6)); return Ok(()); } - // `train [generations] [games per generation] [out dir]` trains a network by self-play + // `train [generations] [games per generation] [out dir] [--from <weights>]` trains a network + // by self-play, starting from `--from`, or the newest generation in the out dir, or random weights Some("train") => { let defaults = train::Config::default(); @@ -38,6 +46,7 @@ fn main() -> std::io::Result<()> { generations: number(2, defaults.generations), games_per_generation: number(3, defaults.games_per_generation), out_dir: arg(4).map_or(defaults.out_dir.clone(), Into::into), + from: from.map(Into::into), ..defaults }; return train::run(&cfg); |
