aboutsummaryrefslogtreecommitdiff
path: root/src/nn_train.py
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2026-09-06 17:24:44 +0100
committertslil <tslil@posteo.de>2026-09-07 19:58:03 +0100
commit7ef68374e8a58684b299b0f46f7ed850d5a87190 (patch)
tree5b6d49cd7eca96fa4d45284018e290938b0e0db5 /src/nn_train.py
parentf9f8f650dc557ea9dbb4652e48c5cdca7ea3c62c (diff)
cleanup, match now plays pairs of symmetric games
Diffstat (limited to 'src/nn_train.py')
-rwxr-xr-xsrc/nn_train.py27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/nn_train.py b/src/nn_train.py
index cde7a98..8f1a73e 100755
--- a/src/nn_train.py
+++ b/src/nn_train.py
@@ -201,8 +201,7 @@ class SelfPlayRecords:
class Net(Module):
def __init__(self, inp_dim: int, hidden: int) -> None:
super().__init__()
- # learned 7-way cell-state embedding (empty, {black, white} x
- # {flat, standing, road}); the slot layout must match nn.c
+ # learned cell-state embedding, see nn.c
self.embedding = Embedding(7, 1)
self.hidden = Linear(inp_dim, hidden, bias=True)
self.output = Linear(hidden, 1, bias=True)
@@ -302,7 +301,7 @@ class Net(Module):
_ = f.write(f"/* {p} */\n")
_ = f.write(f'#include "weights_{size}.h"\n\n')
_ = f.write(
- f"const float {prefix}_embedding[7] =\n"
+ f"const float {prefix}_embedding[{len(E)}] =\n"
f"{{\n{_fmt_flat(E, per_line=7)}\n}};\n\n"
)
_ = f.write(
@@ -548,24 +547,6 @@ def main() -> None:
help="number of previous self-play instances to mix in with current dataset during training",
)
_ = p.add_argument(
- "--eps-start",
- type=float,
- default=0.15,
- help="initial self-play epsilon: in asymmetric self-play one side (chosen at random per game) plays a uniform random move with this probability while the greedy side has its plies recorded",
- )
- _ = p.add_argument(
- "--eps-min",
- type=float,
- default=0.01,
- help="self-play epsilon floor",
- )
- _ = p.add_argument(
- "--eps-decay",
- type=float,
- default=0.9,
- help="per-iteration epsilon decay",
- )
- _ = p.add_argument(
"--td-lambda",
type=float,
default=0.7,
@@ -639,6 +620,10 @@ def main() -> None:
(root / "data").mkdir(exist_ok=True)
champ = setup(size=args.size, root=root)
+
+ num_params = sum(p.numel() for p in champ.parameters() if p.requires_grad)
+ print(f"Number of trainable parameters: {num_params:,}")
+
for iter in range(1, args.iters + 1):
champ = run_step(
batch=args.batch,