rosenthj / Winter

UCI Chess Engine
GNU General Public License v3.0
86 stars 13 forks source link

How to train ? #10

Closed tpl closed 1 year ago

tpl commented 4 years ago

I did: gen_eval_csv filename out_filename. and get three csv files: okok.dynamic.csv, okok.res.csv, okok.static.csv. What to do next ?

rosenthj commented 4 years ago

I need to update my training script so you can use these!

Essentially those three files contain the dynamic features, game result and static features of your dataset and are coupled so line# N is from the same sample in each file. Static features are essentially 8x8xC representations of the boards more static features. At the moment these are specifically the locations of the pawns and kings. ome constant helper channels are assumed and added by the model, but not stored here. These are inputs for a CNN. Dynamic features are the features more usually found in classical engines. E.g. how many squares a piece may or may not be able to reach. Game result is represented as whether the player to move won or did not lose respectively. Full WDL can be inferred from these two features.

After the training script is updated it should be pretty straightforward to run these files through the script. At the end of the training script the header files for the hardcoded NN weights are generated that you can recompile Winter with. This last part is kind of hacky and I will need to change if people start training their own networks, but so far you seem to be the first that tried.

The repository with the training script is the following: https://github.com/rosenthj/WinterTraining

tpl commented 4 years ago

ok, thanks for answer.

rosenthj commented 4 years ago

Wanted to update here with my current plans.

At the moment training is quite awkward for people other than me and I am aware of this. Part of the reason is a bit deliberate as I don't want people wasting too much time before I have come up with a more sustainable solution as the net is hardcoded into the codebase. What this means is that if I update the architecture of the net, any networks previously trained are no longer compatible.

I have a couple things planned to help remedy this issue.

  1. One change I have in mind is that the training script will not just generate the training weights, but will also generate the source and header files for the NN evaluation. This will mean if you train a net with one version of Winter, you can always use it with a newer version as well. The whole approach still feels like a bit of a hack though, so many people will prefer to take advantage of the next point.
  2. I intend to support NNUE networks. Its important to understand that this does not mean I will support NNUE (though I might), just that the network architecture might receive permanent support. This is much easier to do than just supporting general ONNX based neural networks and allows some interaction with other projects, as well as removing reliance on the Winter codebase for people interested in training networks. The main reason I am not necessarily going to fully support and use NNUE in Winter is that I feel a lot of projects will be doing that, so focusing on NNUE might make Winter less unique and interesting in the future.
  3. I would like to update the training script to directly accept a file with EPDs. I suspect for the moment the primary difficulty for people interested in training networks is the lack of documentation coupled with the unclear pipeline. Having the training script be completely end to end would mitigate this problem greatly.
sugizo commented 2 years ago

tested learning feature using Winter on mac build

cd ~/Downloads
git clone https://github.com/rosenthj/Winter
cd Winter
make

1st trial

~/pgn-extract/pgn-extract -s -C -N -V -D -M -Wuci --notags -o ~/winter/eval ~/pgn/merge_cql_extract_fix/mate.pgn
cd ~/winter
./Winter gen_eval_csv ./eval ./dataset

result nothing happen

2nd trial

~/pgn-extract/pgn-extract -s -C -N -V -D -M -Wuci --notags -o ~/winter/eval ~/pgn/merge_cql_extract_fix/mate.pgn
cd ~/winter
./Winter 
gen_eval_csv ./eval ./dataset

result Command not supported in this build. Recompile with -DEVAL_TRAINING

question how to use learning feature using winter ?

rosenthj commented 1 year ago

As of Winter 1.0, this is no longer the approach used to train Winter nets. I will at some point make an update, but the new way will not require directly using Winter. Instead there will be a python script.