In Convolutional Neural Networks(CNNs), the convolution layer is the most import component.
The convolution layer have two 4-dimension arrays: $I \in \mathbb{R}^{num_{in} \times channel_{in} \times h_{in} \times w_{in}}$ and $W \in \mathbb{R}^{num_{w} \times channel_{w} \times h_{w} \times w_{w}}$, and get a 4-dimension array: $O \in \mathbb{R}^{num_{out} \times channel_{out} \times h_{out} \times w_{out}}$, where $num_{out} = num_{in}, channel_{out} = num_{w}, h_{out} = (h_{in} - h_w) / stride_h + 1, w_{out} = (w_{in} - w_w) / stride_w + 1$, and $channel_{in}$ must be equal to $channel_{w}$. $stride_w$, $stride_h$ is the parameters of CNNs.(We ignore other parameters like pad.)
We can use the following formula to represent a simple convolution layer:
$$O[n][m][x][y] = \sum_{c = 0}^{channel_{in} - 1}{\sum_{i=0}^{h_w - 1}{\sum_{j=0}^{w_w - 1}{I[n][c][x \times stride_{h} + i][ y \times stride_w + j] \cdot W[m][c][i][j]}}}$$$$\begin{array}{lll}
n &=& 0,\cdots, num_{out} - 1\\
m &=& 0, \cdots, channel_{out} - 1 \\
x &=& 0, \cdots, h_{out} - 1 \\
y &=& 0, \cdots, w_{out} - 1
\end{array}$$
Today, Xiaoming find a special convolution layer, The value of each element in $I$ and $W$ is either -1 or +1. Please help he compute $O$.