Examples of IWeights


Examples of zdenekdrahos.AI.NeuralNetwork.Weights.IWeights

    }

    public static void printNetworkWeights(INeuralNetwork network) {
        ILayer layer;
        List<IWeight> weights;
        IWeights networkWeights = network.getWeights();

        for (int layerIndex = 1; layerIndex < network.getLayersCount(); layerIndex++) {
            layer = network.getLayer(layerIndex);
            System.out.printf("%d -> %d layer\n", layerIndex - 1, layerIndex);
            for (int neuronIndex = 0; neuronIndex < layer.getNeuronsCount(); neuronIndex++) {
                System.out.printf("%d.neuron = ", neuronIndex);
                weights = networkWeights.getNeuronWeights(layerIndex, neuronIndex);
                for (IWeight weight : weights) {
                    System.out.printf("%f  ", weight.getWeight());
                }
                System.out.println();
            }
View Full Code Here

Examples of zdenekdrahos.AI.NeuralNetwork.Weights.IWeights

    }

    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.