Answers.Body: <p>note that there are newer tools and an official api <a href="https://github.com/LeelaChessZero/lc0/pull/1261" rel="nofollow noreferrer">here</a>!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-11T08:08:20.087Z
Answers.LastActivityDate: 2021-04-11T08:08:20.087Z
Answers.UserDisplayName: Ofek Shochat
Answers.Body: <p>Python utilities for experimenting with Leela Chess Zero a neural network based chess engine: <a href="https://github.com/glinscott/leela-chess/" rel="noreferrer">https://github.com/glinscott/leela-chess/</a></p>
  
  <p>Here: <a href="https://github.com/so-much-meta/lczero_tools" rel="noreferrer">https://github.com/so-much-meta/lczero_tools</a>
  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).</p>
  
  <p><a href="https://github.com/dkappe/leela-chess-weights/wiki/Supervised-Learning" rel="noreferrer">https://github.com/dkappe/leela-chess-weights/wiki/Supervised-Learning</a>
  A newer, faster tool for converting pgn to training data can be found here.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-06T14:27:59.973Z
Answers.Text: Wow, great stuff!
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-22T00:28:48.530Z
Answers.Text: 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.
Answers.UserDisplayName: zfj3ub94rf576hc4eegm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T15:49:32.020Z
Answers.LastActivityDate: 2020-02-05T15:49:32.020Z
Answers.UserDisplayName: edwina oliver
Body: <p>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. </p>
  
  <p>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. </p>
  
  <p>Alternatively an explanation of how the input vectors are computed might enable me to write it myself. </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-05T18:43:56.490Z
Comments.Text: 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.
Comments.UserDisplayName: edwina oliver
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-06T14:29:07.910Z
Comments.Text: The inputvector is the input to the NN. Basically, what the trainingsdata consists of.
Comments.UserDisplayName: BlindKungFuMaster
Tags: <engines><programming><pgn><leela><python>
Title: Is there Python code to use the Leela neural network?
ThreadText: # Is there Python code to use the Leela neural network?
  
  (Asked by: username_0 on 2020-02-05)
  
  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.
  
  **Tags:** engines, programming, pgn, leela, python
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_0**: The inputvector is the input to the NN. Basically, what the trainingsdata consists of.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-02-05. Score: 6 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: Wow, great stuff!  
  > **username_3**: 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.  
  
  ---
  
  ### Answer by username_2 on 2021-04-11. Score: 0
  
  note that there are newer tools and an official api [here](https://github.com/LeelaChessZero/lc0/pull/1261)!
  
  
  ---
  
  