Examples of IWeight


Examples of zdenekdrahos.AI.NeuralNetwork.Weights.IWeight

    private double getErrorInOutputLayer(int neuronIndex) {
        return target[neuronIndex] - currentValues.get(neuronIndex);
    }

    private double getErrorInHiddenLayer(int layerIndex, int neuronIndex) {
        IWeight weight;
        double delta, error = 0;
        int nextLayer = layerIndex + 1;
        int neuronsInNextLayer = network.getLayer(nextLayer).getNeuronsCount();
        for (int nextNeuronIndex = 0; nextNeuronIndex < neuronsInNextLayer; nextNeuronIndex++) {
            delta = weightErrors.get(nextLayer, nextNeuronIndex);
            weight = network.getWeights().getConnectionWeight(nextLayer, nextNeuronIndex, neuronIndex + 1); // +1 because of bias
            error += delta * weight.getWeight();
        }
        return error;
    }
View Full Code Here

Examples of zdenekdrahos.AI.NeuralNetwork.Weights.IWeight

        return error * derivate;
    }

    private void updateWeights() {
        double previousNeuronValue, previousAdjustment, weightAdjustment, newWeight;
        IWeight oldWeight;
        IWeights weights = network.getWeights();
        for (int layerIndex = network.getLayersCount() - 1; layerIndex > 0; layerIndex--) {
            int currentNeuronsCount = network.getLayer(layerIndex).getNeuronsCount();
            int previousNeuronsCount = network.getLayer(layerIndex - 1).getNeuronsCount() + 1;

            for (int neuronIndex = 0; neuronIndex < currentNeuronsCount; neuronIndex++) {
                double neuronDelta = weightErrors.get(layerIndex, neuronIndex);               
                for (int previousNeuronIndex = 0; previousNeuronIndex < previousNeuronsCount; previousNeuronIndex++) {
                    // weight adjustment
                    previousNeuronValue = previousNeuronIndex == 0 ? // bias
                            1 : networkValues.getNeuronValue(layerIndex - 1, previousNeuronIndex - 1);                   
                    previousAdjustment = previousAdjustments.get(layerIndex, neuronIndex, previousNeuronIndex);
                    weightAdjustment = learningRate * neuronDelta * previousNeuronValue + momentum * previousAdjustment;
                    // weights
                    oldWeight = weights.getConnectionWeight(layerIndex, neuronIndex, previousNeuronIndex);                   
                    newWeight = oldWeight.getWeight() + weightAdjustment;
                    // update helper structure and weights in network
                    previousAdjustments.set(layerIndex, neuronIndex, previousNeuronIndex, weightAdjustment);
                    weights.setConnectionWeight(layerIndex, neuronIndex, previousNeuronIndex, newWeight);
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.