src/main/components/network/MoNeuralNetwork.java
// EFFECTS: forward through the neural network in order to get a result
forward through the neural network in order to get a result
forward through the neural network in order to get a result
private void forwardNeuralNetwork(float[] inputs) {
        this.setInputNeurons(inputs);
        for (int i = 1;i < this.layers.length; i++) {
            MoNeuron[] previousLayerNeurons = this.layers[i - 1].getNeurons();
            MoNeuron[] currentLayerMoNeurons = this.layers[i].getNeurons();
            for (int j = 0; j < currentLayerMoNeurons.length; j++) {
                MoNeuron currentNeuron = currentLayerMoNeurons[j];
                float sumOfWeights = 0;
                for (int k = 0; k < previousLayerNeurons.length; k++) {
                    sumOfWeights += currentNeuron.getWeights()[k] * previousLayerNeurons[k].getValue();
                }
                currentNeuron.setValue(MoFunctions.activationFunction(activationFunction,sumOfWeights));
            }
        }
    }
private void forwardNeuralNetwork ( float [ ] inputs ) { this . setInputNeurons ( inputs ) ; for ( int i = 1 ; i < this . layers . length ; i ++ ) { MoNeuron [ ] previousLayerNeurons = this . layers [ i - 1 ] . getNeurons ( ) ; MoNeuron [ ] currentLayerMoNeurons = this . layers [ i ] . getNeurons ( ) ; for ( int j = 0 ; j < currentLayerMoNeurons . length ; j ++ ) { MoNeuron currentNeuron = currentLayerMoNeurons [ j ] ; float sumOfWeights = 0 ; for ( int k = 0 ; k < previousLayerNeurons . length ; k ++ ) { sumOfWeights += currentNeuron . getWeights ( ) [ k ] * previousLayerNeurons [ k ] . getValue ( ) ; } currentNeuron . setValue ( MoFunctions . activationFunction ( activationFunction , sumOfWeights ) ) ; } } }
EFFECTS: forward through the neural network in order to get a result
EFFECTS : forward through the neural network in order to get a result
// @TODO we need to add the bias to the sumOfWeights