Augment one Go training record with a symmetry of its square board. Transform IDs 0, 1, 2, and 3 mean counterclockwise rotations of 0, 90, 180, and 270 degrees. IDs 4 through 7 mean a left-right reflection followed by those same rotations.
state_planes is a NumPy array of shape (C, n, n), where C is the plane count and n is the board size. policy is a floating-point NumPy array of length n squared plus one: board entries in row-major order, followed by pass. Its nonnegative weights need not sum to one; do not normalize them. Apply the same symmetry to every plane and the board entries, leaving pass and value unchanged.
Return a three-item tuple: the transformed state array, transformed policy array, and unchanged scalar value. Both arrays must retain their input shapes and dtypes and use newly allocated storage.
Input: state_planes=[[[1, 2], [3, 4]]], policy=[0.1, 0.2, 0.3, 0.4, 0.5], value=0.25, transform_id=1
Output: ([[[2, 4], [1, 3]]], [0.2, 0.4, 0.1, 0.3, 0.5], 0.25)
Explanation: The state and board-action probabilities receive the same 90 degree counterclockwise rotation, while the pass entry remains last.
Input: state_planes=[[[1, 2], [3, 4]]], policy=[0.1, 0.2, 0.3, 0.4, 0.5], value=-0.5, transform_id=4
Output: ([[[2, 1], [4, 3]]], [0.2, 0.1, 0.4, 0.3, 0.5], -0.5)
Input: state_planes=[[[7]]], policy=[0.6, 0.4], value=1.0, transform_id=7
Output: ([[[7]]], [0.6, 0.4], 1.0)
np.rot90 accepts axes=(-2, -1) to rotate every plane together.
np.flip with axis=-1 reflects the board from left to right.
Array.copy prevents transformed views from sharing the input storage.
Accepts: array
Accepts: array
Accepts: number
Accepts: number
Augment one Go training record with a symmetry of its square board. Transform IDs 0, 1, 2, and 3 mean counterclockwise rotations of 0, 90, 180, and 270 degrees. IDs 4 through 7 mean a left-right reflection followed by those same rotations.
state_planes is a NumPy array of shape (C, n, n), where C is the plane count and n is the board size. policy is a floating-point NumPy array of length n squared plus one: board entries in row-major order, followed by pass. Its nonnegative weights need not sum to one; do not normalize them. Apply the same symmetry to every plane and the board entries, leaving pass and value unchanged.
Return a three-item tuple: the transformed state array, transformed policy array, and unchanged scalar value. Both arrays must retain their input shapes and dtypes and use newly allocated storage.
Input: state_planes=[[[1, 2], [3, 4]]], policy=[0.1, 0.2, 0.3, 0.4, 0.5], value=0.25, transform_id=1
Output: ([[[2, 4], [1, 3]]], [0.2, 0.4, 0.1, 0.3, 0.5], 0.25)
Explanation: The state and board-action probabilities receive the same 90 degree counterclockwise rotation, while the pass entry remains last.
Input: state_planes=[[[1, 2], [3, 4]]], policy=[0.1, 0.2, 0.3, 0.4, 0.5], value=-0.5, transform_id=4
Output: ([[[2, 1], [4, 3]]], [0.2, 0.1, 0.4, 0.3, 0.5], -0.5)
Input: state_planes=[[[7]]], policy=[0.6, 0.4], value=1.0, transform_id=7
Output: ([[[7]]], [0.6, 0.4], 1.0)
np.rot90 accepts axes=(-2, -1) to rotate every plane together.
np.flip with axis=-1 reflects the board from left to right.
Array.copy prevents transformed views from sharing the input storage.
Accepts: array
Accepts: array
Accepts: number
Accepts: number