Minor fixes

This commit is contained in:
2026-03-31 16:26:28 +02:00
parent 165a2bc977
commit 5aca7b87e3
4 changed files with 19 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ package com.naaturel.ANN;
import com.naaturel.ANN.domain.model.neuron.Neuron;
import com.naaturel.ANN.domain.abstraction.Trainer;
import com.naaturel.ANN.implementation.gradientDescent.Linear;
import com.naaturel.ANN.implementation.multiLayers.Sigmoid;
import com.naaturel.ANN.implementation.multiLayers.TanH;
import com.naaturel.ANN.implementation.training.GradientBackpropagationTraining;
@@ -18,12 +19,12 @@ public class Main {
public static void main(String[] args){
int nbrClass = 3;
int nbrClass = 1;
DataSet dataset = new DatasetExtractor()
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_4_14.csv", nbrClass);
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_2_9.csv", nbrClass);
int[] neuronPerLayer = new int[]{27, dataset.getNbrLabels()};
int[] neuronPerLayer = new int[]{10, 5, 5, dataset.getNbrLabels()};
int nbrInput = dataset.getNbrInputs();
List<Layer> layers = new ArrayList<>();
@@ -51,7 +52,7 @@ public class Main {
FullyConnectedNetwork network = new FullyConnectedNetwork(layers.toArray(new Layer[0]));
Trainer trainer = new GradientBackpropagationTraining();
trainer.train(0.0001F, 15000, network, dataset);
trainer.train(0.0005F, 15000, network, dataset);
GraphVisualizer visualizer = new GraphVisualizer();
@@ -60,13 +61,13 @@ public class Main {
visualizer.addPoint("Label " + label.getFirst(), entry.getData().get(0).getValue(), entry.getData().get(1).getValue());
}
float min = -5F;
float max = 5F;
float step = 0.025F;
float min = 0F;
float max = 15F;
float step = 0.03F;
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;
float predSeries = prediction > 0.5F ? 1 : -1;
visualizer.addPoint(Float.toString(predSeries), x, y);
}
}