Implement one valid two-dimensional convolution layer using the cross-correlation convention common in neural networks. The input has shape (N,Cin,H,W), the weights have shape (Cout,Cin,KH,KW), and the bias has shape (Cout,).
For every output position, compute
yn,c,i,j=d=1∑Cinu=0∑KH−1v=0∑KW−1xn,d,i+u,j+vWc,d,u,v+bcThe output height is H−KH+1 and the output width is W−KW+1. Return a floating-point NumPy array with shape (N,Cout,H−KH+1,W−KW+1).
Input: x = [[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]], W = [[[[1, 1], [1, 1]]]], b = [0]
Output: [[[[4.0, 4.0], [4.0, 4.0]]]]
Explanation: Every 2 by 2 input patch and kernel product sums to 4.
patch = x[n, :, i:i + kernel_height, j:j + kernel_width] selects one receptive field.
np.sum(patch * W[output_channel]) combines all input channels and kernel positions.
Initialize the output with np.zeros((N, C_out, H_out, W_out), dtype=float).
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array
Implement one valid two-dimensional convolution layer using the cross-correlation convention common in neural networks. The input has shape (N,Cin,H,W), the weights have shape (Cout,Cin,KH,KW), and the bias has shape (Cout,).
For every output position, compute
yn,c,i,j=d=1∑Cinu=0∑KH−1v=0∑KW−1xn,d,i+u,j+vWc,d,u,v+bcThe output height is H−KH+1 and the output width is W−KW+1. Return a floating-point NumPy array with shape (N,Cout,H−KH+1,W−KW+1).
Input: x = [[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]], W = [[[[1, 1], [1, 1]]]], b = [0]
Output: [[[[4.0, 4.0], [4.0, 4.0]]]]
Explanation: Every 2 by 2 input patch and kernel product sums to 4.
patch = x[n, :, i:i + kernel_height, j:j + kernel_width] selects one receptive field.
np.sum(patch * W[output_channel]) combines all input channels and kernel positions.
Initialize the output with np.zeros((N, C_out, H_out, W_out), dtype=float).
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array