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

  // Itereate through all nodes in curLayer to update their outputs
  for (let i = 0; i < curLayer.length; i++) {
    let curNode = curLayer[i];
    let preNode = curNode.inputLinks[0].source;
    let coordinate = curNode.inputLinks[0].weight;
    // Take advantage of the dummy weights
    curNode.output = preNode.output[coordinate[0]][coordinate[1]];
  }
}
Flatten a previous 2D layer (conv2d or maxpool2d). The flatten order matches
tf2.keras' implementation: channel -> row -> column.
@param {[Node]} curLayer Flatten layer