Skip to content

Commit

Permalink
Removing main from project
Browse files Browse the repository at this point in the history
* main class was there to test the NN functionality by solving XOR
  • Loading branch information
Kim Feichtinger authored and Kim Feichtinger committed Mar 5, 2018
1 parent a0b79ad commit 1bbb6f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
target
target
out
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ This is a very basic Java Neural Network library using EJML (Efficient Java Matr

## TODO

- add support for multy-layered Neural Networks
- Add support for multy-layered Neural Net works
52 changes: 0 additions & 52 deletions src/main/java/Main.java

This file was deleted.

16 changes: 12 additions & 4 deletions src/main/java/NeuralNetwork.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import org.ejml.simple.SimpleMatrix;
import utilities.Sigmoid;

import java.util.Arrays;
import java.util.Random;

/**
* Created by KimFeichtinger on 04.03.18.
*/
public class NeuralNetwork {

private static final double LEARNING_RATE = 0.1;

Random r = new Random();

private double learningRate = 0.1;

// "size" of the neural network
private int inputNodes;
private int hiddenNodes;
Expand Down Expand Up @@ -93,7 +92,7 @@ private SimpleMatrix calculateLayer(SimpleMatrix weights, SimpleMatrix bias, Sim
private SimpleMatrix calculateGradient(SimpleMatrix layer, SimpleMatrix error){
SimpleMatrix gradient = Sigmoid.applySigmoid(layer, true);
gradient = gradient.elementMult(error);
return gradient.scale(LEARNING_RATE);
return gradient.scale(learningRate);
}

private SimpleMatrix calculateDeltas(SimpleMatrix gradient, SimpleMatrix layer){
Expand All @@ -104,4 +103,13 @@ private SimpleMatrix arrayToMatrix(double[] i){
double[][] input = {i};
return new SimpleMatrix(input).transpose();
}

public double getLearningRate() {
return learningRate;
}

public void setLearningRate(double learningRate) {
this.learningRate = learningRate;
}

}

0 comments on commit 1bbb6f5

Please sign in to comment.