Apply the two-convolution residual block used in the AlphaGo Zero tower. For input X, convolution weights W1 and W2, channel scales γ1 and γ2, channel shifts β1 and β2, and batch normalization BN over batch and spatial axes, compute
H=ReLU(BN(Conv3×3(X;W1);γ1,β1)) Y=ReLU(X+BN(Conv3×3(H;W2);γ2,β2))Here, H is the residual branch activation and Y is the block output. Both convolutions use stride 1, padding 1, and no bias.
For an activation z in one channel, batch normalization is
BN(z;γ,β)=γσ2+εz−μ+βHere, mu and sigma squared are that channel's mean and population variance over the batch and spatial dimensions. Gamma and beta are its supplied scale and shift, and epsilon is the supplied positive normalization constant.
Return Y as a PyTorch float32 tensor with the same shape and device as x.
Input: x = [[[[2,-1],[0,3]]]], conv1_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale1 = [1], shift1 = [0], conv2_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale2 = [1], shift2 = [0], epsilon = 0.00001
Output: [[[[2.0,0.0],[0.0,3.0]]]]
Explanation: The convolution branch is zero, so the final ReLU acts on the shortcut.
Input: x = [[[[-2]]]], conv1_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale1 = [1], shift1 = [0], conv2_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale2 = [1], shift2 = [0], epsilon = 0.0001
Output: [[[[0.0]]]]
Input: x shape = (2,2,2,2), conv1_weight shape = (2,2,3,3), conv2_weight shape = (2,2,3,3), scale1 = [0.5856,0.6118], shift1 = [-0.0436,-0.0539], scale2 = [0.9551,0.978], shift2 = [0.3145,-0.1452], epsilon = 0.00001
Output: 32-bit floating-point tensor with shape (2,2,2,2)
F.conv2d supports the padding needed to preserve spatial dimensions.
keepdim=True keeps channel statistics broadcastable.
Reshape a channel vector to (1, channels, 1, 1) for broadcasting.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: number
Apply the two-convolution residual block used in the AlphaGo Zero tower. For input X, convolution weights W1 and W2, channel scales γ1 and γ2, channel shifts β1 and β2, and batch normalization BN over batch and spatial axes, compute
H=ReLU(BN(Conv3×3(X;W1);γ1,β1)) Y=ReLU(X+BN(Conv3×3(H;W2);γ2,β2))Here, H is the residual branch activation and Y is the block output. Both convolutions use stride 1, padding 1, and no bias.
For an activation z in one channel, batch normalization is
BN(z;γ,β)=γσ2+εz−μ+βHere, mu and sigma squared are that channel's mean and population variance over the batch and spatial dimensions. Gamma and beta are its supplied scale and shift, and epsilon is the supplied positive normalization constant.
Return Y as a PyTorch float32 tensor with the same shape and device as x.
Input: x = [[[[2,-1],[0,3]]]], conv1_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale1 = [1], shift1 = [0], conv2_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale2 = [1], shift2 = [0], epsilon = 0.00001
Output: [[[[2.0,0.0],[0.0,3.0]]]]
Explanation: The convolution branch is zero, so the final ReLU acts on the shortcut.
Input: x = [[[[-2]]]], conv1_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale1 = [1], shift1 = [0], conv2_weight = [[[[0,0,0],[0,0,0],[0,0,0]]]], scale2 = [1], shift2 = [0], epsilon = 0.0001
Output: [[[[0.0]]]]
Input: x shape = (2,2,2,2), conv1_weight shape = (2,2,3,3), conv2_weight shape = (2,2,3,3), scale1 = [0.5856,0.6118], shift1 = [-0.0436,-0.0539], scale2 = [0.9551,0.978], shift2 = [0.3145,-0.1452], epsilon = 0.00001
Output: 32-bit floating-point tensor with shape (2,2,2,2)
F.conv2d supports the padding needed to preserve spatial dimensions.
keepdim=True keeps channel statistics broadcastable.
Reshape a channel vector to (1, channels, 1, 1) for broadcasting.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: number