convolute = (curLayer) => {
  console.assert(curLayer[0].type === 'conv', 'Wrong layer type');

  // Itereate through all nodes in curLayer to update their outputs
  curLayer.forEach(node => {
    /*
     * Accumulate the single conv result matrices from previous channels.
     * Previous channels (node) are accessed by the reference in Link objects.
     */
    let newOutput = init2DArray(node.output.length, node.output.length, 0);

    for (let i = 0; i < node.inputLinks.length; i++) {
      let curLink = node.inputLinks[i];
      let curConvResult = singleConv(curLink.source.output, curLink.weight);
      newOutput = matrixAdd(newOutput, curConvResult);
    }

    // Add bias to all element in the output
    let biasMatrix = init2DArray(newOutput.length, newOutput.length, node.bias);
    newOutput = matrixAdd(newOutput, biasMatrix);

    node.output = newOutput;
  })
}
Convolution operation. This function update the outputs property of all nodes
in the given layer. Previous layer is accessed by the reference in nodes'
links.
@param {[Node]} curLayer Conv layer.