Troubles with Texel Tuning

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

sandermvdb
Posts: 160
Joined: Sat Jan 28, 2017 1:29 pm
Location: The Netherlands

Re: Troubles with Texel Tuning

Post by sandermvdb »

You could have a look at the source of my Texel tuning implementation which worked marvelously. It calculates the local optimum for quiet positions.
I would also start with tuning the material scores. Maybe your rooks for instance are scored too high so it is being compensated in the psqt.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Troubles with Texel Tuning

Post by Daniel Shawul »

Start simple, for instance with piece values. You don't need millions of positions here either. The goal is to verify that the method works. It should converge on ok-ish piece values starting from 0 in a few minutes. There is no point in running it overnight unless you know it works.
Is it really possible to get good piece values when all are initialized to 0 or a 100 ? I think you would atleast need to run it through a global optimizer, e.g. genetic algorithm (GE), to get rough values. The GEs actually accept a range such as [0, 1000] hence it doesn't really matter which initial values we use. Also they take way too many trials than needed by local methods so a few minutes might not be enough. Ofcourse the local optimizers are fast once we are in the proximity of the minima.

Another issue is the quality of the dataset; it should contain many positions with material imbalances for the purpose of tuning piece values.

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

Re: Troubles with Texel Tuning

Post by AlvaroBegue »

Daniel Shawul wrote:
Start simple, for instance with piece values. You don't need millions of positions here either. The goal is to verify that the method works. It should converge on ok-ish piece values starting from 0 in a few minutes. There is no point in running it overnight unless you know it works.
Is it really possible to get good piece values when all are initialized to 0 or a 100 ? I think you would atleast need to run it through a global optimizer, e.g. genetic algorithm (GE), to get rough values. The GEs actually accept a range such as [0, 1000] hence it doesn't really matter which initial values we use. Also they take way too many trials than needed by local methods so a few minutes might not be enough. Ofcourse the local optimizers are fast once we are in the proximity of the minima.

Another issue is the quality of the dataset; it should contain many positions with material imbalances for the purpose of tuning piece values.

Daniel
Yes, tuning just material values is very easy, and gradient descent will find the right values no matter where you start. I demonstrated this in RuyTune using a fancy second-order method (L-BFGS), but any other gradient descent method would work too.
AndrewGrant
Posts: 1754
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Troubles with Texel Tuning

Post by AndrewGrant »

I think I implemented SGD properly. All of my piece values make relative sense, ie knight ~= bishop, queen > rook, pawn < rest.

But I got rather low values for my pawns. ~60 when only tuning the piece values, and ~40 when tuning piece values + PSQT. Also, my knight in the midgame is worth as much as a rook (by piece value)

How likely is it that these values being low or too high, is just a result of the tuner compensating for me over valuing certain pawn features? Maybe my rook bonuses are too high in the midgame, so my rook value is lowered?

Either way, I plan on opening almost every param to the tuner tonight, and we shall see.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Troubles with Texel Tuning

Post by AlvaroBegue »

AndrewGrant wrote:I think I implemented SGD properly. All of my piece values make relative sense, ie knight ~= bishop, queen > rook, pawn < rest.

But I got rather low values for my pawns. ~60 when only tuning the piece values, and ~40 when tuning piece values + PSQT. Also, my knight in the midgame is worth as much as a rook (by piece value)
Are you still using non-quiescent positions in your training data? I would recommend replacing each position with node where the quiescence search got its score. Things make a lot more sense in those conditions.
AndrewGrant
Posts: 1754
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Troubles with Texel Tuning

Post by AndrewGrant »

I am using 725K quiet positions that was posted by another user.

Found here : http://www.talkchess.com/forum/viewtopic.php?t=61427
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Troubles with Texel Tuning

Post by AlvaroBegue »

AndrewGrant wrote:I am using 725K quiet positions that was posted by another user.

Found here : http://www.talkchess.com/forum/viewtopic.php?t=61427
I can offer you the positions I use. The format is fairly obvious: https://bitbucket.org/alonamaloh/ruy_tu ... th_results

The positions are generated by going through a collection of computer-computer games downloaded from CCRL, having RuyDos search starting from those positions, and collecting the position of the 1000th call to the evaluation function. I then ran very quick Stockfish-vs-Stockfish games starting from those positions to assign labels to them. Finally I modified the positions using quiescence search the way I described earlier. I think this procedure should get rid of many of the biases that other collection methods may have. In particular, I think you'll find many more uneven-material positions here.
AndrewGrant
Posts: 1754
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Troubles with Texel Tuning

Post by AndrewGrant »

I will run using your positions when I get back to my desktop. Thanks!
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Troubles with Texel Tuning

Post by Daniel Shawul »

AlvaroBegue wrote: Yes, tuning just material values is very easy, and gradient descent will find the right values no matter where you start. I demonstrated this in RuyTune using a fancy second-order method (L-BFGS), but any other gradient descent method would work too.
I still think the initial values are so important for any local method. Even for a toy problem like optimizing the rosenbrok functions, gradient methods fail if i pick the wrong initial values. See below.

Code: Select all

def rosen&#40;x&#41;&#58;
    """The Rosenbrock function"""
    print x
    return sum&#40;100.0*&#40;x&#91;1&#58;&#93;-x&#91;&#58;-1&#93;**2.0&#41;**2.0 + &#40;1-x&#91;&#58;-1&#93;)**2.0&#41;

x0 = np.array&#40;&#91;13, 0.7, 0.8, 1.9, 1.2&#93;)
res = minimize&#40;rosen, x0, method='BFGS', options=&#123;'xtol'&#58; 1e-8, 'disp'&#58; True&#125;)
Setting x0[0]=1 gives 1.0 for all pameters.

Do you have the source code and database you used to tune piece values for demonstration purposes?

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

Re: Troubles with Texel Tuning

Post by AlvaroBegue »

Daniel Shawul wrote:
AlvaroBegue wrote: Yes, tuning just material values is very easy, and gradient descent will find the right values no matter where you start. I demonstrated this in RuyTune using a fancy second-order method (L-BFGS), but any other gradient descent method would work too.
I still think the initial values are so important for any local method. Even for a toy problem like optimizing the rosenbrok functions, gradient methods fail if i pick the wrong initial values. See below.

Code: Select all

def rosen&#40;x&#41;&#58;
    """The Rosenbrock function"""
    print x
    return sum&#40;100.0*&#40;x&#91;1&#58;&#93;-x&#91;&#58;-1&#93;**2.0&#41;**2.0 + &#40;1-x&#91;&#58;-1&#93;)**2.0&#41;

x0 = np.array&#40;&#91;13, 0.7, 0.8, 1.9, 1.2&#93;)
res = minimize&#40;rosen, x0, method='BFGS', options=&#123;'xtol'&#58; 1e-8, 'disp'&#58; True&#125;)
Setting x0[0]=1 gives 1.0 for all pameters.

Do you have the source code and database you used to tune piece values for demonstration purposes?

Daniel
Yes. Just download the repository here: https://bitbucket.org/alonamaloh/ruy_tune

The file sample/tune.cpp contains an example that finds the material values. The file sample/evaluation_parameters has the initial guesses, which are all 0.