matthewlai wrote:mcostalba wrote:Can't you still evaluate the terms in order of largest weights? I wonder if the weights in your matrices are mostly uniform, or some are much larger than others?matthewlai wrote: Then you can cut it off at any point where all the remaining smaller terms can't add up to be larger than any of the bigger terms.
But I can't do that because I have no idea how my eval() works. It's just a bunch of matrices.
Searching using slow eval with tactical verification
Moderators: hgm, Rebel, chrisw
-
- Posts: 94
- Joined: Thu Feb 27, 2014 8:19 pm
Re: Searching using slow eval with tactical verification
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: Searching using slow eval with tactical verification
It would be possible if the network has no hidden layers. With 2 hidden layers it's impossible to do something like this.thomasahle wrote: Can't you still evaluate the terms in order of largest weights? I wonder if the weights in your matrices are mostly uniform, or some are much larger than others?
Also, when evaluating full matrices I can use the CPU's SIMD instructions, which are many times faster than scalar instructions. If I had to evaluate more than 10% or so of the weights, it would be more efficient to just evaluate the whole thing.
Also, matrix-vector multiplications are usually bound by memory bandwidth (as opposed to matrix-matrix multiplications, which are usually bound by CPU), and since weights are loaded in cache line units, evaluating some of the weights may require loading most of the matrices anyways.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
-
- Posts: 227
- Joined: Mon Sep 12, 2011 11:27 pm
- Location: Moscow, Russia
Re: Searching using slow eval with tactical verification
SmarThink eval function is very slow so I've implemented an original lazy eval approach.
And at any next IID iteration I'm going to update this "lazy window":
So if the root eval is 0 at any iteration I will have window [-200;200] for depth 0, [-205;205] at depth 1, [-250;250] at root depth 10 and so on. All evaluation outside this window will be replaced with only material eval. Surprisingly it works for me. If you're interested you can try it)
I will be glad for any feedback)
Code: Select all
int LazyEval(void)
{
int material = thread_board.Material[thread_board.SideToMove] - thread_board.Material[ChangeSide(thread_board.SideToMove)];
int min_lazy, max_lazy;
if (CurSide == thread_board.SideToMove)
{
min_lazy = root.min_material_lazy;
max_lazy = root.max_material_lazy;
}
else
{
min_lazy = -root.max_material_lazy;
max_lazy = -root.min_material_lazy;
}
if (material < min_lazy)
{
if ((thread_board.PieceCount[PAWN][ChangeSide(thread_board.SideToMove)] > 1 || thread_board.NumOfPieces[ChangeSide(thread_board.SideToMove)] > 9) && (thread_board.NumOfPieces[ChangeSide(thread_board.SideToMove)] > 5))
{
if (thread_board.SideToMove)
{
if (black_pawns_bb & FULLROW(1)) material += 100;
else if (black_pawns_bb & FULLROW(2)) material += 50;
}
else
{
if (white_pawns_bb & FULLROW(6)) material += 100;
else if (white_pawns_bb & FULLROW(5)) material += 50;
}
if (material < min_lazy) return material;
}
}
else if (material > max_lazy)
{
if ((thread_board.PieceCount[PAWN][thread_board.SideToMove] > 1 || thread_board.NumOfPieces[thread_board.SideToMove] > 9) && (thread_board.NumOfPieces[thread_board.SideToMove] > 5))
{
if (thread_board.SideToMove)
{
if (white_pawns_bb & FULLROW(6)) material -= 100;
else if (white_pawns_bb & FULLROW(5)) material -= 50;
}
else
{
if (black_pawns_bb & FULLROW(1)) material -= 100;
else if (black_pawns_bb & FULLROW(2)) material -= 50;
}
if (material > max_lazy) return material;
}
}
return INFINITY;
}
Code: Select all
void RecalcLazyBounds(int root_depth)
{
root.root_material = thread_board.Material[CurSide] - thread_board.Material[ChangeSide(CurSide)];
root.min_material_lazy = MIN(root_move_eval[0], root.root_material) - 200 - root_depth * 5 + MIN(150, MAX(-150, root_move_eval[0] / 5));
root.max_material_lazy = MAX(root_move_eval[0], root.root_material) + 200 + root_depth * 5 + MIN(150, MAX(-150, root_move_eval[0] / 5));
}
I will be glad for any feedback)
The Force Be With You!