Stockfish NNUE net question: Why 40k input nodes?

Discussion of chess software programming and technical issues.

Moderator: Ras

rdhoffmann
Posts: 54
Joined: Fri Apr 21, 2023 3:46 pm
Full name: Richard Hoffmann

Stockfish NNUE net question: Why 40k input nodes?

Post by rdhoffmann »

So the Stockfish NNUE input network is basically Kingpos*AllPieces ~ 40k input nodes, for both sides.

Now a very simple question, why not 64 networks for each king position instead? Wouldn't that be a whole lot easier to train and give the same result?
syzygy
Posts: 5694
Joined: Tue Feb 28, 2012 11:56 pm

Re: Stockfish NNUE net question: Why 40k input nodes?

Post by syzygy »

rdhoffmann wrote: Tue May 23, 2023 11:44 pm So the Stockfish NNUE input network is basically Kingpos*AllPieces ~ 40k input nodes, for both sides.

Now a very simple question, why not 64 networks for each king position instead? Wouldn't that be a whole lot easier to train and give the same result?
I think you'd have to train them all at the same time or they will not be calibrated to each other? Also, if you train on games, you train on sets of positions where the king moves around.
rdhoffmann
Posts: 54
Joined: Fri Apr 21, 2023 3:46 pm
Full name: Richard Hoffmann

Re: Stockfish NNUE net question: Why 40k input nodes?

Post by rdhoffmann »

Ah, that is a good point yes. About the moving king, sorting/filtering positions according to the king square should be fairly trivial. Another option is to generate only positions where the king is on a fixed square. This is what I did for some experiments, to avoid a huge training effort before knowing whether an idea actually works.
alvinypeng
Posts: 36
Joined: Thu Mar 03, 2022 7:29 am
Full name: Alvin Peng

Re: Stockfish NNUE net question: Why 40k input nodes?

Post by alvinypeng »

rdhoffmann wrote: Tue May 23, 2023 11:44 pm So the Stockfish NNUE input network is basically Kingpos*AllPieces ~ 40k input nodes, for both sides.

Now a very simple question, why not 64 networks for each king position instead? Wouldn't that be a whole lot easier to train and give the same result?
I'm not sure if this idea is possible because a Stockfish network requires both black and white perspectives. The output of a network doesn't depend on the position of just one king - it depends on both.
rdhoffmann
Posts: 54
Joined: Fri Apr 21, 2023 3:46 pm
Full name: Richard Hoffmann

Re: Stockfish NNUE net question: Why 40k input nodes?

Post by rdhoffmann »

True- makes perfect sense. Thank you for your replies! :)
syzygy
Posts: 5694
Joined: Tue Feb 28, 2012 11:56 pm

Re: Stockfish NNUE net question: Why 40k input nodes?

Post by syzygy »

alvinypeng wrote: Wed May 24, 2023 2:23 am
rdhoffmann wrote: Tue May 23, 2023 11:44 pm So the Stockfish NNUE input network is basically Kingpos*AllPieces ~ 40k input nodes, for both sides.

Now a very simple question, why not 64 networks for each king position instead? Wouldn't that be a whole lot easier to train and give the same result?
I'm not sure if this idea is possible because a Stockfish network requires both black and white perspectives. The output of a network doesn't depend on the position of just one king - it depends on both.
One can fix one king and let the other king run free. (Or one can fix both kings and train a network for each (wK, bK) position pair.)
But the problem that I see is that in games both kings tend to move at least now and then.

But I haven't touched a trainer so far, so I could be seeing problems that do not exist.