lantonov / asmFish

A continuation of the nice project asmFish by Mohammed Li. Latest version: 07.08.2019
https://lantonov.github.io/asmFish/
Other
118 stars 49 forks source link

Neural Network Stuff #28

Closed lantonov closed 7 years ago

lantonov commented 7 years ago

I made a simple plain vanilla NN in Python with adjustable layers. This is its take on the MNIST data set with 30 hidden nodes:

       Epoch 0: 9062 / 10000
       Epoch 1: 9196 / 10000
       Epoch 2: 9199 / 10000
       Epoch 3: 9307 / 10000
       Epoch 4: 9353 / 10000
       Epoch 5: 9381 / 10000
       Epoch 6: 9381 / 10000
       Epoch 7: 9398 / 10000
       Epoch 8: 9383 / 10000
       Epoch 9: 9419 / 10000
       Epoch 10: 9418 / 10000
       Epoch 11: 9421 / 10000
       Epoch 12: 9457 / 10000
       Epoch 13: 9456 / 10000
       Epoch 14: 9452 / 10000
       Epoch 15: 9438 / 10000
       Epoch 16: 9466 / 10000
       Epoch 17: 9461 / 10000
       Epoch 18: 9458 / 10000
       Epoch 19: 9488 / 10000
       Epoch 20: 9457 / 10000
       Epoch 21: 9473 / 10000
       Epoch 22: 9451 / 10000
       Epoch 23: 9491 / 10000
       Epoch 24: 9473 / 10000
       Epoch 25: 9484 / 10000
       Epoch 26: 9466 / 10000
       Epoch 27: 9486 / 10000
       Epoch 28: 9493 / 10000
       Epoch 29: 9467 / 10000

With optimisation of hyperparameters and regularisation (L2) I can make it reach 99%. To start a serious work, first I need to make some helper programs to extract and work with FENs and evaluations, translate them in the necessary input format and create a database to be used for network training and testing. Also, these discussions, including the closed issues will be moved to Wiki in respective topics to be easier to find them for reference.

lantonov commented 7 years ago

Completed the first tests of the NN (67, 128, 64, 10) with actual chess positions. The results are encouraging. With 10925 positions and using the common logistic activation function, it starts from 3545/10925 (32.45%) and reaches to 10678/10925 (97.74%). With the ramp function, the same as used by Moha in his experiments, starting from 3545/10925 (32.45%) it reaches 10493/10925 (96.05%). The progress depends upon the settings of hyperparameters (eta and lambda), especially in later stages (above 94%) which take also the most time. Before this, I made a helper program to extract positions from TCEC games (these 10925 positions are from TCEC 9 Superfinal) and their evaluations in separate files. The program ignores positions from the opening, for which there are no evaluations. Another helper program converted these FEN positions to format convenient for input into NN (67 nodes). A third helper program converted evaluations into categorical variables (10 categories). This was necessary because I wanted to use exactly the same NN which was used for the MNIST data (which are categorical). A preprocessor program converted the input arrays into explicit numpy arrays exactly the same as those used for the MNIST data. All programs (helpers and NN), I wrote in Python at which I am a little better than at assembly.

Ipmanchess commented 7 years ago

Wow..sounds incredibly good..even i don't understand anything..but these helper programs could maybe also use my games database then?!

lantonov commented 7 years ago

Ipman, I will give you the link to these programs in pm in tcec chat. In spite of my sloppy programming, these helper programs turned out to be surprisingly fast. Extracting positions / evals from the Superfinal took less than 3 seconds. Extracting pos / evals for the whole TCEC 9 (some 300,000+) took about a minute. The other reformatting programs are comparably fast, too. The extractor programs can be made to extract pos / evals from any database with only a small one-liner tweak which is database-dependent. If you send me a game from your database, I can make it Ipman-specific. Below is the look of the first 3 games from the superfinal

r1b1k2r/2qnbppp/p2ppn2/1p4B1/3NPPP1/P1N5/1PP1Q2P/2KR1B1R b kq - 0 11
r1b1k2r/2qnbpp1/p2ppn1p/1p4B1/3NPPP1/P1N5/1PP1Q2P/2KR1B1R w kq - 0 12
r1b1k2r/2qnbpp1/p2ppn1p/1p6/3NPPPB/P1N5/1PP1Q2P/2KR1B1R b kq - 1 12
r3k2r/1bqnbpp1/p2ppn1p/1p6/3NPPPB/P1N5/1PP1Q2P/2KR1B1R w kq - 2 13
r3k2r/1bqnbpp1/p2ppn1p/1p6/3NPPPB/P1N5/1PP1Q1BP/2KR3R b kq - 3 13
2r1k2r/1bqnbpp1/p2ppn1p/1p6/3NPPPB/P1N5/1PP1Q1BP/2KR3R w k - 4 14
2r1k2r/1bqnbpp1/p2ppn1p/1p6/3NPPPB/P1N5/1PP1Q1BP/2KRR3 b k - 5 14
2r1k2r/1bq1bpp1/pn1ppn1p/1p6/3NPPPB/P1N5/1PP1Q1BP/2KRR3 w k - 6 15
2r1k2r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P6/8 w - - 0 45
4b3/8/7k/8/p6P/K4p2/1P6/4B3 b - - 1 45
4b3/8/8/7k/p6P/K4p2/1P6/4B3 w - - 2 46
4b3/8/8/7k/p6P/KP3p2/8/4B3 b - - 0 46
4b3/8/8/7k/p6P/KP6/5p2/4B3 w - - 0 47
4b3/8/8/7k/p6P/KP6/5B2/8 b - - 0 47
4b3/8/8/7k/7P/Kp6/5B2/8 w - - 0 48
lantonov commented 7 years ago

I have another very simple idea which I will certainly try when I get more experienced with neural networks. Instead of evals of positions (or parallel to them), the network outputs best moves, for which it has been trained with many positions using supervised learning. Moves can be output in many ways using more than one output nodes. For instance, using 64 output nodes, NN can output a move in the format from:to, e.g. from = 1 and to = 2. Evals may be needed if we have 2 or more candidate moves and have to decide which is better. Eventually, during reinforcement learning, we may ditch evals completely counting only on win / loss as a criterion for good / bad moves.

tthsqe12 commented 7 years ago

How are you measuring this 97% ? As I said before, I tried to match the output of the evaluation function with a net and was getting on average 60cp error.

lantonov commented 7 years ago

60cp is not a big error. And it can be much improved with training. I transformed the evals to categories in order to use exactly the same NN as used for MNIST data. Thus, eval 0.00 is 0,0,0,0,1,0,0,0,0,0; 0.00 < eval < 0.20 is 0,0,0,0,0,1,0,0,0,0; 0.20 < eval < 0.50 is 0,0,0,0,0,0,1,0,0,0; -0.20 > eval < 0.00 is 0,0,0,1,0,0,0,0,0,0 and so on. This gives 10 output nodes, just like the MNIST data. The NN is the same as for MNIST with minimal changes (to make it compatible with Python 3.x instead of Python 2.x). The percentages are just positions that are guessed correctly divided by the total positions (10925) x 100. It is the same criterion as for MNIST (% correctly guessed digits). Arguably, a regression NN (1 output node with floating numbers) is better than classification NN and converges faster. However, I preferred this classification NN at the beginning to be directly comparable with a well-known textbook case from which I can adjust the hyperparameters and the architecture. Additional benefit is that such classification network can directly be used to output moves without the need to evaluate the position.

lantonov commented 7 years ago

These high percentages are reached when I make many cycles of training with the same data. If, after such training, I change the data set, the percentages fall again to below 40%. So, previous learning has a small impact on the new positions. This is understandable because positions have so many distinctive features. It is not only the pattern, but also the relationships between the pieces. To have a sensible progress on new positions, many cycles with different data sets presented in different sequences are needed. No escape from that bore, unfortunately. Maybe some tricks to speed up learning will become handy. In any case, supervised learning will be a long process and evals are the unavoidable first stage. Thinking ahead, to the output of moves instead of evaluations, I stashed several ideas in my head. First, it is more convenient programmatically to represent moves in long algebraic notation (LAN) instead of SAN, such as e2e4 d7d5 g1f3 instead of e4 d5 Nf3. LAN is useful because the move can be easily separated in from:to parts (arrays). Second, the output can be divided in 2 arrays of 64 elements each, one for the "from" part and the other for the "to" part so that the move is a 1 in the "from" array and a 1 in the "to" array. Third, it is necessary to have two masks (filters) for the 2 output arrays. These masks are deterministic but are different for the different positions. The masks are determined by the possible legal moves for the given position which every chess program knows. These legal moves are again divided to from:to parts. The "from" parts make the mask for the "from" output array and the "to" mask is for the "to" output array. When training the net, it should learn not only the places of the two ones in the output arrays but also the masks for the given position. This should teach the net to actually "play" chess, i.e. the rules for moving pieces.

lantonov commented 7 years ago

I learned something important today. In order for the net to learn effectively the inputs and outputs should be between 0 and 1 with the average of 0.5. In such a way, the central, most sensitive part of the activating function is used making the learning process faster. I will try this first and then rewrite the net prog to transform it from a classifier to regressor. The criterion for the later will be the error (cost) which is tried to minimise instead of the percentage successes.

lantonov commented 7 years ago

I converted the net to a regressor (67, 128, 64, 1) and tested it with the 10925 positions data set. eval / 130 and inputs / 10 to make them be between -1 and 1. The results were disappointing. The error quickly fell in the first 5 epoch from 95 cp to 64 cp and stayed there for next 1000 epochs (30 iterations each). This has all the features of the Vanishing gradient problem. I will try several things to improve the situation, first diminishing the number of layers to 67, 64, 1 and then playing with hyperparameters, inputs and outputs. If unsuccessful, try a different network (a regressor Support Vector Machine (SVM)). In case of failure with regressor, I will switch back to classifier.

lantonov commented 7 years ago

In this blog, the guy trains the MNIST data on a SVM with adjusting the hyperparameters. He finds that the best inputs are between -1 and 1. Also, use grid search tool for finding the best hyperparameters (eta and lambda for my network). For estimating the length of training that is required, I have to determine the variance and spectrum of the chess data (positions) with PCA and compare it with the MNIST data.

lantonov commented 7 years ago

I have a moderate success with the regressor. Curbing the net to a single hidden layer of 30 nodes (67, 30, 1) and with some combination of HPs (eta 2.4-2.6, lambda = 0.0, i.e. in practice without L2), I reach a quadratic cost from 0.456 to 0.374 for 100 iterations (the formula for quadratic cost is similar to that of variation). Not happy with this as I don't have a criterion if it's good or not. Quadratic cost depends on many things beside the performance. The above percentages for accuracy are a better measure.

lantonov commented 7 years ago

https://github.com/mr-press/DeepChess Interesting link where both evaluation and search are done by the network. It just compares 2 positions and chooses the better one. No evaluation (numerical score) of position, no alpha-beta search. The network is something, however. CUDA (GPUs) is almost mandatory for running it. It's the same paper Ipman showed us: http://www.cs.tau.ac.il/~wolf/papers/deepchess.pdf On my lowly dual-core 32bit playing just 2 ply deep from the starting position took it 10 minutes. It played 1. Nf3

Ipmanchess commented 7 years ago

Maybe some more info..check also these sub-links in this topic (http://www.talkchess.com/forum/viewtopic.php?t=63458)

lantonov commented 7 years ago

This will be reopened or new topic created eventually

lantonov commented 7 years ago

This excerpt from the AlphaGo paper in Nature started me thinking that Neural Networking and distributed computing are not very far apart:

"We also implemented a distributed APV-MCTS algorithm. This architecture consists of a single master machine that executes the main search, many remote worker CPUs that execute asynchronous rollouts, and many remote worker GPUs that execute asynchronous policy and value network evaluations. The entire search tree is stored on the master, which only executes the in-tree phase of each simulation. The leaf positions are communicated to the worker CPUs, which execute the rollout phase of simulation, and to the worker GPUs, which compute network features and evaluate the policy and value networks. The prior probabilities of the policy network are returned to the master, where they replace placeholder prior probabilities at the newly expanded node. The rewards from rollouts and the value network outputs are each returned to the master, and backed up the originating search path."