public void calculate(){
        super.calculate();

        if(learningMode){
            int i=0;
            for(Neuron neuron : neurons){
                Map<Neuron, Double> weights = neuron.getWeights();
                for(Neuron prevLayerNeuron : weights.keySet()){
                    double weight = weights.get(prevLayerNeuron);

                    double derivative = 1.0;
                    if(ActivationFunctionType.TANSIG.equals(activationFunctionType)){
                        derivative = 1.0 - Math.pow(new TansigActivationFunciton().calculate(prevLayerNeuron.getOutput()*weight), 2);
                    }
                    double newWeight = weight + learningParameters.getAlpha()*(expectedOutput[i]-prevLayerNeuron.getOutput()*weight)*derivative*prevLayerNeuron.getOutput();
                    try {
                        neuron.updateWeight(prevLayerNeuron, newWeight);
                    } catch (ConnectionNotExistsException e) {
                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                    }
                }
                i++;

            }
        }
    }