lorserker / ben

a game engine for bridge
GNU General Public License v3.0
41 stars 30 forks source link

Running Training of BEN #51

Closed ThorvaldAagaard closed 1 year ago

ThorvaldAagaard commented 1 year ago

When running bidding_nn.py there is printed a variable on each iteration called c_train

What does that value express?

Can it be used to lower the number of iterations?

This is the output from my latest run image

eamongalligan62 commented 1 year ago

The last time I ran bidding_nn.py c-train was reaching 0.55 or 0.56 and I stopped at 4884000 iterations ... I think it means neural is learning 5.5% on the runs

The bidding_nn_continue.py does 1 million iterations so if you reach 1 million from where you started it will end unless you change the code ... my last 2 runs were from 2884000 and 3884000 so it stopped at 4884000 ... when doing the binfo training that stops after 500000 so I editted the code to 1500000 iterations

eamongalligan62 commented 1 year ago

However I think I spotted a bigger issue tonight ....the thing about the 2 3 4 5 6 7 spots might be dropping the odd trick ...saw defending with Q72 of trumps and when following suit to a losing high card it threw trump 7 and declarer got K5 thus leaving declarer with tenace K5 over Q2 ....I saw in my past musings something about randomizing the spots in the code.... Not sure if I am on the money here but I saw with my own eyes last night and have the pbn file ...thanks Eamon Galligan

ThorvaldAagaard commented 1 year ago

It is correct, that it randomize the discard of spot cards.

lorserker commented 1 year ago

c_train is the cost. that is what the nn optimizes when it learns. it tries to make it smaller. the cost measures how many mistakes the nn makes when predicting bids. in this case we use cross-entropy as the cost function

ThorvaldAagaard commented 1 year ago

So would it be OK to stop the iteration, when c_train is below 0.05 (or after 1,000.000 iterations)?

lorserker commented 1 year ago

yes, it's ok to stop training at any time. it makes sense to stop it when the cost doesn't decrease anymore

ThorvaldAagaard commented 1 year ago

I can see that the model being used has number of iterations in the name, so perhaps it is best to stay with fixed iterations.

I assume that all the files generated for each iteration then in fact could be used for bidding, so I could set up a match between models/gib21_model/gib21-1000000 and models/gib21_model/gib21-500000 to see if there is any improvement gained with the last 500.000 iterations

lorserker commented 1 year ago

yes, the tensorflow saver keeps the last N files. i think that i have set it to 50 or 100. after that it starts deleting the old ones.

eamongalligan62 commented 1 year ago

Currently I run training using 150 hands and display every 5000 My training only keeps about the previous 4 files and I never changed anything Currently my c-train display is around .055 which is still descending and in my world indicates NN is still gaining 5% learning. but I am not sure this is the meaning.

lorserker commented 1 year ago

.05 is just a measure and it doesn't mean percentage

Muppet1 commented 1 year ago

Don't forget the version on this site doesn't work at all for training as I pointed out.

You have to use the original.

ThorvaldAagaard commented 1 year ago

It should all work. Let me know, what the problem is, and I will update the documentation (or fix the error)

Muppet1 commented 1 year ago

first I have not downloaded anything in the last month so I am not talking about anything you have changed.

at that point the trainer was basically broken and you got ctrain values that were much lower than the original and the nets did not learn anything.

So to make the most recent nets I made I had to use the original trainer from a long time ago.

I am not competent enough to know what was changed that broke it.

I will when I get chance download the latest version and see what you have done. It sounds great. I basically stopped because I wanted to play long matches single dummy rather than double dummy which I could do.

I was talking to Edward Piowar about getting ben to work with his program so I could do that. And then using it to generate the next generation of data. I found his program was the quickest way to make data.

ThorvaldAagaard commented 1 year ago

Yes, I remember there was an error in the python script, that I have fixed (The issue #49)

Edward Piwowar can generate files directly used for training - you just need to archive a ben-file, I have added scripts for processing, and printing the deals in a much more convenient way, and you can start playing directly from a webpage. I am the only one that has used it, so please let me know about any challenges.

ThorvaldAagaard commented 1 year ago

Closing this as my question is answered