public void testCNNConstruction() {
NeuralNetworkImpl nn = NNFactory.convNN(new int[][] { { 32, 32, 1 }, { 5, 5, 6, 1 }, { 2, 2 }, { 5, 5, 16, 1 }, { 2, 2 }, { 5, 5, 120, 1 }, {84}, {10} }, true);
assertEquals(13, nn.getLayers().size(), 0);
Layer l = nn.getInputLayer().getConnections().get(0).getOutputLayer();
Conv2DConnection cc = (Conv2DConnection) nn.getInputLayer().getConnections().get(0);
assertEquals(28, cc.getOutputFeatureMapRows(), 0);
assertEquals(28, cc.getOutputFeatureMapColumns(), 0);
assertEquals(6, cc.getOutputFilters(), 0);
Subsampling2DConnection sc = (Subsampling2DConnection) l.getConnections().get(2);
l = l.getConnections().get(2).getOutputLayer();
assertEquals(14, sc.getOutputFeatureMapRows(), 0);
assertEquals(14, sc.getOutputFeatureMapColumns(), 0);
assertEquals(6, sc.getFilters(), 0);
cc = (Conv2DConnection) l.getConnections().get(1);
l = l.getConnections().get(1).getOutputLayer();
assertEquals(10, cc.getOutputFeatureMapRows(), 0);
assertEquals(10, cc.getOutputFeatureMapColumns(), 0);
assertEquals(16, cc.getOutputFilters(), 0);
sc = (Subsampling2DConnection) l.getConnections().get(2);
l = l.getConnections().get(2).getOutputLayer();
assertEquals(5, sc.getOutputFeatureMapRows(), 0);
assertEquals(5, sc.getOutputFeatureMapColumns(), 0);
assertEquals(16, sc.getFilters(), 0);
cc = (Conv2DConnection) l.getConnections().get(1);
l = l.getConnections().get(1).getOutputLayer();
assertEquals(1, cc.getOutputFeatureMapRows(), 0);
assertEquals(1, cc.getOutputFeatureMapColumns(), 0);
assertEquals(120, cc.getOutputFilters(), 0);
GraphConnections cg = (GraphConnections) l.getConnections().get(2);
assertEquals(84, cg.getConnectionGraph().getRows(), 0);
GraphConnections cg2 = (GraphConnections) cg.getOutputLayer().getConnections().get(2);