Build a compact AlphaGo Zero network from supplied parameter tensors. Let B be the batch size, N the board size, C the trunk width, Cp the policy-head width, Cv the value-head width, and H the value hidden width. The input X has shape (B, Cin, N, N), where Cin is its channel count.
The trunk uses trunk_weight for its 3 by 3 convolution and trunk_scale and trunk_shift for normalization, followed by ReLU. All convolutions use stride 1 and no bias; padding is 1 for 3 by 3 kernels and 0 for 1 by 1 kernels.
H0=ReLU(BN(Conv3×3(X)))For a feature tensor Z, channel normalization computes the mean μ and population variance σ2 over the batch and spatial dimensions. The supplied per-channel scale γ, shift δ, and positive constant ε are then applied as follows.
BN(Z)=γσ2+εZ−μ+δEach residual block applies two padded 3 by 3 convolutions. The first normalization is followed by ReLU, while the second is followed by the shortcut addition and ReLU. Every residual-block dictionary contains:
Here Rk is the residual branch output and Hk is the shared feature tensor after block k. The policy head uses a 1 by 1 convolution, normalization, ReLU, flattening, and a linear projection to produce one raw logit per board action plus pass. The value head uses its own 1 by 1 convolution, normalization, ReLU, hidden projection followed by ReLU, and tanh-bounded scalar projection. Flattening preserves the batch dimension and orders entries by channel, row, then column. Linear weights store output features by input features. The output-head dictionary contains:
Here, K is the number of supplied residual blocks, L is the policy-logit tensor, and v is the value tensor. Return the tuple (L,v) as 32-bit floating-point tensors on the input device, with shapes (B, N squared plus one) and (B,) respectively.
Input: x = [[[[1]]]], trunk_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], trunk_scale = [1], trunk_shift = [1], residual_parameters = [{"scale1":[1],"scale2":[1],"shift1":[0],"shift2":[0],"conv1_weight":[[[[0,0,0],[0,0,0],[0,0,0]]]],"conv2_weight":[[[[0,0,0],[0,0,0],[0,0,0]]]]}], head_parameters = {"value_scale":[1],"value_shift":[1],"policy_scale":[1],"policy_shift":[1],"value_conv_weight":[[[[0]]]],"value_hidden_bias":[0],"value_output_bias":[0],"policy_conv_weight":[[[[0]]]],"policy_linear_bias":[0,0],"value_hidden_weight":[[1]],"value_output_weight":[[1]],"policy_linear_weight":[[1],[2]]}, epsilon = 0.00001
Output: ([[1.0,2.0]], [0.761594])
Explanation: Each zero convolution is replaced by its normalization shift, and the value branch returns tanh(1).
Input: x shape = (1,1,1,1), trunk_weight shape = (1,1,3,3), trunk_scale = [1], trunk_shift = [0], residual_parameters = [], head_parameters contains policy_linear_weight shape (2,1) and value_hidden_weight shape (1,1), epsilon = 0.00001
Output: ([[0.5,-0.5]], [0.964028])
Input: x shape = (1,1,2,2), trunk_weight shape = (1,1,3,3), trunk_scale = [1], trunk_shift = [1], residual_parameters contains two blocks, head_parameters contains policy_linear_weight shape (5,4) and value_hidden_weight shape (1,4), epsilon = 0.00001
Output: (float32 tensor with shape (1,5), float32 tensor with shape (1,))
A normalization helper can be reused with each stage's own scale and shift.
Keep the block input available for the residual addition.
flatten(1) preserves one policy vector and one value per batch item.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: object
Accepts: number
Build a compact AlphaGo Zero network from supplied parameter tensors. Let B be the batch size, N the board size, C the trunk width, Cp the policy-head width, Cv the value-head width, and H the value hidden width. The input X has shape (B, Cin, N, N), where Cin is its channel count.
The trunk uses trunk_weight for its 3 by 3 convolution and trunk_scale and trunk_shift for normalization, followed by ReLU. All convolutions use stride 1 and no bias; padding is 1 for 3 by 3 kernels and 0 for 1 by 1 kernels.
H0=ReLU(BN(Conv3×3(X)))For a feature tensor Z, channel normalization computes the mean μ and population variance σ2 over the batch and spatial dimensions. The supplied per-channel scale γ, shift δ, and positive constant ε are then applied as follows.
BN(Z)=γσ2+εZ−μ+δEach residual block applies two padded 3 by 3 convolutions. The first normalization is followed by ReLU, while the second is followed by the shortcut addition and ReLU. Every residual-block dictionary contains:
Here Rk is the residual branch output and Hk is the shared feature tensor after block k. The policy head uses a 1 by 1 convolution, normalization, ReLU, flattening, and a linear projection to produce one raw logit per board action plus pass. The value head uses its own 1 by 1 convolution, normalization, ReLU, hidden projection followed by ReLU, and tanh-bounded scalar projection. Flattening preserves the batch dimension and orders entries by channel, row, then column. Linear weights store output features by input features. The output-head dictionary contains:
Here, K is the number of supplied residual blocks, L is the policy-logit tensor, and v is the value tensor. Return the tuple (L,v) as 32-bit floating-point tensors on the input device, with shapes (B, N squared plus one) and (B,) respectively.
Input: x = [[[[1]]]], trunk_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], trunk_scale = [1], trunk_shift = [1], residual_parameters = [{"scale1":[1],"scale2":[1],"shift1":[0],"shift2":[0],"conv1_weight":[[[[0,0,0],[0,0,0],[0,0,0]]]],"conv2_weight":[[[[0,0,0],[0,0,0],[0,0,0]]]]}], head_parameters = {"value_scale":[1],"value_shift":[1],"policy_scale":[1],"policy_shift":[1],"value_conv_weight":[[[[0]]]],"value_hidden_bias":[0],"value_output_bias":[0],"policy_conv_weight":[[[[0]]]],"policy_linear_bias":[0,0],"value_hidden_weight":[[1]],"value_output_weight":[[1]],"policy_linear_weight":[[1],[2]]}, epsilon = 0.00001
Output: ([[1.0,2.0]], [0.761594])
Explanation: Each zero convolution is replaced by its normalization shift, and the value branch returns tanh(1).
Input: x shape = (1,1,1,1), trunk_weight shape = (1,1,3,3), trunk_scale = [1], trunk_shift = [0], residual_parameters = [], head_parameters contains policy_linear_weight shape (2,1) and value_hidden_weight shape (1,1), epsilon = 0.00001
Output: ([[0.5,-0.5]], [0.964028])
Input: x shape = (1,1,2,2), trunk_weight shape = (1,1,3,3), trunk_scale = [1], trunk_shift = [1], residual_parameters contains two blocks, head_parameters contains policy_linear_weight shape (5,4) and value_hidden_weight shape (1,4), epsilon = 0.00001
Output: (float32 tensor with shape (1,5), float32 tensor with shape (1,))
A normalization helper can be reused with each stage's own scale and shift.
Keep the block input available for the residual addition.
flatten(1) preserves one policy vector and one value per batch item.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: object
Accepts: number