Change signature of train method
This commit is contained in:
@@ -6,8 +6,10 @@ import com.naaturel.ANN.implementation.multiLayers.Sigmoid;
|
||||
import com.naaturel.ANN.implementation.multiLayers.TanH;
|
||||
import com.naaturel.ANN.implementation.training.GradientBackpropagationTraining;
|
||||
import com.naaturel.ANN.infrastructure.dataset.DataSet;
|
||||
import com.naaturel.ANN.infrastructure.dataset.DataSetEntry;
|
||||
import com.naaturel.ANN.infrastructure.dataset.DatasetExtractor;
|
||||
import com.naaturel.ANN.domain.model.neuron.*;
|
||||
import com.naaturel.ANN.infrastructure.graph.GraphVisualizer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -15,13 +17,13 @@ public class Main {
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
int nbrInput = 25;
|
||||
int nbrClass = 4;
|
||||
|
||||
int[] neuronPerLayer = new int[]{10, nbrClass};
|
||||
int nbrClass = 1;
|
||||
|
||||
DataSet dataset = new DatasetExtractor()
|
||||
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_3_5.csv", nbrClass);
|
||||
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_4_12.csv", nbrClass);
|
||||
|
||||
int[] neuronPerLayer = new int[]{10, dataset.getNbrLabels()};
|
||||
int nbrInput = dataset.getNbrInputs();
|
||||
|
||||
List<Layer> layers = new ArrayList<>();
|
||||
for (int i = 0; i < neuronPerLayer.length; i++){
|
||||
@@ -38,7 +40,7 @@ public class Main {
|
||||
|
||||
Bias bias = new Bias(new Weight());
|
||||
|
||||
Neuron n = new Neuron(syns, bias, new TanH());
|
||||
Neuron n = new Neuron(syns, bias, new Sigmoid(2));
|
||||
neurons.add(n);
|
||||
}
|
||||
Layer layer = new Layer(neurons);
|
||||
@@ -48,7 +50,28 @@ public class Main {
|
||||
FullyConnectedNetwork network = new FullyConnectedNetwork(layers);
|
||||
|
||||
Trainer trainer = new GradientBackpropagationTraining();
|
||||
trainer.train(network, dataset);
|
||||
trainer.train(0.5F, network, dataset);
|
||||
|
||||
/*GraphVisualizer visualizer = new GraphVisualizer();
|
||||
|
||||
for (DataSetEntry entry : dataset) {
|
||||
List<Float> label = dataset.getLabelsAsFloat(entry);
|
||||
visualizer.addPoint("Label " + label.getFirst(), entry.getData().get(0).getValue(), entry.getData().get(1).getValue());
|
||||
}
|
||||
|
||||
float min = -2F;
|
||||
float max = 2F;
|
||||
float step = 0.01F;
|
||||
for (float x = min; x < max; x+=step){
|
||||
for (float y = min; y < max; y+=step){
|
||||
float prediction = network.predict(List.of(new Input(x), new Input(y))).getFirst();
|
||||
float predSeries = prediction > 0.5F ? 1 : 0;
|
||||
visualizer.addPoint(Float.toString(predSeries), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
visualizer.buildScatterGraph();*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user