private void trainTestPass(double[] inputs, double[] expected, double[] actual) {

        // Calculate the error.
        double[] errors = new double[actual.length];
        for (int error = 0; error < actual.length; error++) {
            
            errors[error] = expected[error] - actual[error];
        }

        // Calculate the delta values for the medial layer.
        double[][] deltas = new double[network.getLayerCount()][];
        double[][] weights = network.getOutputLayer().getWeights();
        double[] neuronOutputs = errors;
        for (int layer = network.getLayerCount() - 1; layer >= 0; layer--) {
            
            deltas[layer] = getDeltaValues(weights, neuronOutputs);

            weights = network.getLayer(layer).getWeights();
            neuronOutputs = deltas[layer];
        }

        // Adjust weights.
        double[] currentInputs = inputs;
        for (int layer = 0; layer < network.getLayerCount(); layer++) {
            
            for (int input = 0; input < currentInputs.length; input++) {
                
                for (int neuron = 0; neuron < network.getMedialNeurons(); neuron++) {
                    
                    double weightUpdate = currentInputs[input] * deltas[layer][neuron]
                            * dLogistic(network.getLayer(layer).getLastOutputs()[neuron]);
                    
                    double adjustment = learningRate * weightUpdate + momentum
                            * network.getLayer(layer).getLastAdjustment(input, neuron);
                    
                    network.getLayer(layer).adjustWeight(input, neuron, adjustment);
                }
            }

            currentInputs = network.getLayer(layer).getLastOutputs();
        }

        // Adjust weights of the last layer.
        for (int neuron = 0; neuron < currentInputs.length; neuron++) {
            
            for (int output = 0; output < network.getOutputs(); output++) {
                
                double weightUpdate = currentInputs[neuron] * errors[output];
                
                double adjustment = learningRate * weightUpdate + momentum
                        * network.getOutputLayer().getLastAdjustment(neuron, output);
                
                network.getOutputLayer().adjustWeight(neuron, output, adjustment);
            }
        }

        return;
    }