tuning for the uninformed

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: derivatives, scaling

Post by jdart »

If your calculus is rusty, you can use this online tool:

https://www.derivative-calculator.net/

I handle midgame/endgame weighting as follows: each parameter has an entry in an array that is a structure and includes how it should be scaled.

Each time a gradient is updated, I call a scale method that applies the scaling factor for the associated parameter.

See tune.cpp and specifically the scale method here:

https://github.com/jdart1/arasan-chess

--Jon
fierz
Posts: 72
Joined: Mon Mar 07, 2016 4:41 pm
Location: Zürich, Switzerland

Re: tuning for the uninformed

Post by fierz »

Is there anyone who has a large epd file for download somewhere with the results of the games?

cheers
Martin
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: tuning for the uninformed

Post by AlvaroBegue »

fierz wrote:Is there anyone who has a large epd file for download somewhere with the results of the games?
Give this a try: https://bitbucket.org/alonamaloh/ruy_tu ... th_results
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: tuning for the uninformed

Post by jdart »

I have done something similar.

It has occurred to me, though, that the current tuning method would work just the same if each position had a winning probability, not just a 0, 0.5, 1 result. So if you really want to burn a lot of CPU cycles, you could run a match of say, 10 games with each position. The result would be a training set with more accurate labels.

--Jon
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: tuning for the uninformed

Post by AlvaroBegue »

jdart wrote:I have done something similar.

It has occurred to me, though, that the current tuning method would work just the same if each position had a winning probability, not just a 0, 0.5, 1 result. So if you really want to burn a lot of CPU cycles, you could run a match of say, 10 games with each position. The result would be a training set with more accurate labels.

--Jon
I don't have a strong argument for why I think this, but I think if you had 10 times the CPU budget to spare, you would be better off having 10 times as many positions labelled by a single game.
flok

Re: tuning for the uninformed

Post by flok »

AlvaroBegue wrote: Tue Nov 28, 2017 8:37 pm [I downloaded games from CCRL, took positions from those games and analyzed them with my program RuyDos. I saved positions on which the evaluation function was being called after searching 1000 nodes. I then labelled each position by running one very quick SF8-vs-SF8 game.

https://bitbucket.org/alonamaloh/ruy_tu ... th_results

EDIT: In that file each position has been replaced by the position from which quiescence search got its score.
In that file, we can see for example:

6k1/8/p4P1B/3b4/1pp3B1/7P/1R4P1/6K1 b - - 1-0

Now is that 1-0 for win for white or for black? I'm asking as it is now black that can move.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: tuning for the uninformed

Post by AlvaroBegue »

1-0 for white. I use the same format of the "Result" tag in PGN.
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: tuning for the uninformed

Post by flok »

Something I forgot to ask:

for
totalError += pow(value_from_fen - calculateSigmoid(eval_score), 2);

value_from_fen = 1.0 for 1-0, 0.0 for 0-1 and so on

but eval_score, should it be from the point of view of the fen-string? or from white? or...?
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: tuning for the uninformed

Post by Sven »

flok wrote: Wed Jun 26, 2019 6:21 pm Something I forgot to ask:

for
totalError += pow(value_from_fen - calculateSigmoid(eval_score), 2);

value_from_fen = 1.0 for 1-0, 0.0 for 0-1 and so on

but eval_score, should it be from the point of view of the fen-string? or from white? or...?
Obviously the sigmoid function (and therefore also eval_score) must represent a value from the same viewpoint as value_from_fen. Otherwise you would get a high "error" e.g. if value_from_fen = 1, it is black's turn, and your eval function returns a high score in favor of white so that the sigmoid function returns a value close to 0 (from black viewpoint).
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: tuning for the uninformed

Post by flok »

Sven wrote: Wed Jun 26, 2019 6:45 pm
flok wrote: Wed Jun 26, 2019 6:21 pm Something I forgot to ask:

for
totalError += pow(value_from_fen - calculateSigmoid(eval_score), 2);

value_from_fen = 1.0 for 1-0, 0.0 for 0-1 and so on

but eval_score, should it be from the point of view of the fen-string? or from white? or...?
Obviously the sigmoid function (and therefore also eval_score) must represent a value from the same viewpoint as value_from_fen. Otherwise you would get a high "error" e.g. if value_from_fen = 1, it is black's turn, and your eval function returns a high score in favor of white so that the sigmoid function returns a value close to 0 (from black viewpoint).
Ok, is what I thought to be honest but as the results are currently garbage, I wondered if I maybe did it wrong.

Thanks!