src/core/network/NeuralNetwork.java
public void build() throws NeuralNetworkException {
        if (!neuralNetworkLayers.isEmpty()) throw new NeuralNetworkException("Neural network is already built.");

        neuralNetworkLayers.add(inputLayer);
        neuralNetworkLayers.addAll(hiddenLayers);
        neuralNetworkLayers.add(outputLayer);

        int neuralNetworkLayersSize = neuralNetworkLayers.size();

        boolean hasRecurrentLayers = false;
        for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
            if (neuralNetworkLayers.get(layerIndex).isRecurrentLayer()) {
                hasRecurrentLayers = true;
                break;
            }
        }
        if (hasRecurrentLayers) {
            for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
                if (!neuralNetworkLayers.get(layerIndex).worksWithRecurrentLayer()) {
                    throw new NeuralNetworkException(LayerFactory.getLayerTypeByName(neuralNetworkLayers.get(layerIndex)) + " layer does not work with recurrent layers.");
                }
            }
        }

        for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
            neuralNetworkLayers.get(layerIndex).setNextLayer(neuralNetworkLayers.get(layerIndex + 1));
            neuralNetworkLayers.get(layerIndex + 1).setPreviousLayer(neuralNetworkLayers.get(layerIndex));
        }

        for (NeuralNetworkLayer neuralNetworkLayer : neuralNetworkLayers) neuralNetworkLayer.initializeDimensions();
    }
/**
     * Builds neural network.<br>
     * Connects layers to each other.<br>
     * Initializes layers.<br>
     *
     * @throws NeuralNetworkException thrown if initialization of layer fails or neural network is already built.
     */
Builds neural network.
Connects layers to each other.
Initializes layers.

@throws NeuralNetworkException thrown if initialization of layer fails or neural network is already built.
Builds neural network . Connects layers to each other . Initializes layers . @throws NeuralNetworkException thrown if initialization of layer fails or neural network is already built .
public void build() throws NeuralNetworkException {
        if (!neuralNetworkLayers.isEmpty()) throw new NeuralNetworkException("Neural network is already built.");
        neuralNetworkLayers.add(inputLayer);
        neuralNetworkLayers.addAll(hiddenLayers);
        neuralNetworkLayers.add(outputLayer);
        int neuralNetworkLayersSize = neuralNetworkLayers.size();
        boolean hasRecurrentLayers = false;
        for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
            if (neuralNetworkLayers.get(layerIndex).isRecurrentLayer()) {
                hasRecurrentLayers = true;
                break;
            }
        }
        if (hasRecurrentLayers) {
            for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
                if (!neuralNetworkLayers.get(layerIndex).worksWithRecurrentLayer()) {
                    throw new NeuralNetworkException(LayerFactory.getLayerTypeByName(neuralNetworkLayers.get(layerIndex)) + " layer does not work with recurrent layers.");
                }
            }
        }
        for (int layerIndex = 0; layerIndex <neuralNetworkLayersSize - 1; layerIndex++) {
            neuralNetworkLayers.get(layerIndex).setNextLayer(neuralNetworkLayers.get(layerIndex + 1));
            neuralNetworkLayers.get(layerIndex + 1).setPreviousLayer(neuralNetworkLayers.get(layerIndex));
        }
        for (NeuralNetworkLayer neuralNetworkLayer : neuralNetworkLayers) neuralNetworkLayer.initializeDimensions();
    }
public void build ( ) throws NeuralNetworkException { if ( ! neuralNetworkLayers . isEmpty ( ) ) throw new NeuralNetworkException ( "Neural network is already built." ) ; neuralNetworkLayers . add ( inputLayer ) ; neuralNetworkLayers . addAll ( hiddenLayers ) ; neuralNetworkLayers . add ( outputLayer ) ; int neuralNetworkLayersSize = neuralNetworkLayers . size ( ) ; boolean hasRecurrentLayers = false ; for ( int layerIndex = 0 ; layerIndex < neuralNetworkLayersSize - 1 ; layerIndex ++ ) { if ( neuralNetworkLayers . get ( layerIndex ) . isRecurrentLayer ( ) ) { hasRecurrentLayers = true ; break ; } } if ( hasRecurrentLayers ) { for ( int layerIndex = 0 ; layerIndex < neuralNetworkLayersSize - 1 ; layerIndex ++ ) { if ( ! neuralNetworkLayers . get ( layerIndex ) . worksWithRecurrentLayer ( ) ) { throw new NeuralNetworkException ( LayerFactory . getLayerTypeByName ( neuralNetworkLayers . get ( layerIndex ) ) + " layer does not work with recurrent layers." ) ; } } } for ( int layerIndex = 0 ; layerIndex < neuralNetworkLayersSize - 1 ; layerIndex ++ ) { neuralNetworkLayers . get ( layerIndex ) . setNextLayer ( neuralNetworkLayers . get ( layerIndex + 1 ) ) ; neuralNetworkLayers . get ( layerIndex + 1 ) . setPreviousLayer ( neuralNetworkLayers . get ( layerIndex ) ) ; } for ( NeuralNetworkLayer neuralNetworkLayer : neuralNetworkLayers ) neuralNetworkLayer . initializeDimensions ( ) ; }
Builds neural network.<br>
 Connects layers to each other.<br>
 Initializes layers.<br>
Builds neural network . <br > Connects layers to each other . <br > Initializes layers . <br >