I am interested in doing some analyses of chess games using the neural network trained for Lc0. To that end I need to be able to turn PGN into the right kind of input vectors and to load and use the neural network trained for Leela chess.

My question is whether there is python code for this somewhere. Especially for the first step, using the neural network shouldn't be a problem.

Alternatively an explanation of how the input vectors are computed might enable me to write it myself.

  • I do not find input vector listed in any lco documentation that I found. Is that an alternate NN type word for something else in leela or lc0? I tend to infer that the input vector is the output of the NN but I may be misled by other sites discussing their versions of NN use. Commented Feb 5, 2020 at 18:43
  • The inputvector is the input to the NN. Basically, what the trainingsdata consists of. Commented Feb 6, 2020 at 14:29

2 Answers 2


Python utilities for experimenting with Leela Chess Zero a neural network based chess engine: https://github.com/glinscott/leela-chess/

Here: https://github.com/so-much-meta/lczero_tools This allows you to run the network in Python on specific board positions via python-chess, and get policy/value outputs. (Works with pytorch, and is also able to run the network using the tfprocess training module included in Leela).

https://github.com/dkappe/leela-chess-weights/wiki/Supervised-Learning A newer, faster tool for converting pgn to training data can be found here.

  • 1
    Wow, great stuff! Commented Feb 6, 2020 at 14:27
  • This answer is mostly out of date and not helpful in 2023. The second link is an abandoned repo which contains another link with no example code. Commented Jan 22, 2023 at 0:28

note that there are newer tools and an official api here!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.