A Go position means the same thing after any rotation or reflection of the board. AlphaGo uses this twice: every expert position is added to the training set in all 8 orientations, and at test time a position can be evaluated in all 8 orientations with the outputs mapped back and averaged. Implement the transforms and the explicit ensemble.
Implement dihedral(planes, move, j), ensemble_policy(policy_fn, planes) and ensemble_value(value_fn, planes).
The transform , for , acts on an map:
np.rot90(m, j) does);dihedral(planes, move, j): planes is an array of shape (C, N, N); move is a point index (row , column ). Return (new_planes, new_move): every plane transformed by , and the index of the point where the move's point lands.
ensemble_policy(policy_fn, planes): policy_fn maps a (C, N, N) array to an (N, N) array of move probabilities. Return the (N, N) array : evaluate each transformed position, map each output back to the original orientation with the inverse transform, and average.
ensemble_value(value_fn, planes): value_fn maps a (C, N, N) array to a float. Return the float mean of the 8 values.