Initial commit
This commit is contained in:
57
src/main/java/com/naaturel/ANN/Main.java
Normal file
57
src/main/java/com/naaturel/ANN/Main.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.naaturel.ANN;
|
||||
|
||||
import com.naaturel.ANN.domain.abstraction.Neuron;
|
||||
import com.naaturel.ANN.domain.model.dataset.DataSet;
|
||||
import com.naaturel.ANN.domain.model.dataset.DataSetEntry;
|
||||
import com.naaturel.ANN.domain.model.dataset.Label;
|
||||
import com.naaturel.ANN.domain.model.neuron.Bias;
|
||||
import com.naaturel.ANN.domain.model.neuron.Input;
|
||||
import com.naaturel.ANN.domain.model.neuron.Synapse;
|
||||
import com.naaturel.ANN.domain.model.neuron.Weight;
|
||||
import com.naaturel.ANN.implementation.activationFunction.Heaviside;
|
||||
import com.naaturel.ANN.implementation.activationFunction.Linear;
|
||||
import com.naaturel.ANN.implementation.neuron.SimplePerceptron;
|
||||
import com.naaturel.ANN.implementation.training.GradientDescentTraining;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
DataSet dataSet = new DataSet(Map.ofEntries(
|
||||
Map.entry(new DataSetEntry(List.of(1.0F, 6.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(7.0F, 9.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(1.0F, 9.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(7.0F, 10.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(2.0F, 5.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(2.0F, 7.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(2.0F, 8.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(6.0F, 8.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(6.0F, 9.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(3.0F, 5.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(3.0F, 6.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(3.0F, 8.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(3.0F, 9.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(5.0F, 7.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(5.0F, 8.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(5.0F, 10.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(5.0F, 11.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(4.0F, 6.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(4.0F, 7.0F)), new Label(-1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(4.0F, 9.0F)), new Label(1.0F)),
|
||||
Map.entry(new DataSetEntry(List.of(4.0F, 10.0F)), new Label(1.0F))
|
||||
));
|
||||
|
||||
List<Synapse> syns = new ArrayList<>();
|
||||
syns.add(new Synapse(new Input(0), new Weight()));
|
||||
syns.add(new Synapse(new Input(0), new Weight()));
|
||||
|
||||
Bias bias = new Bias(new Weight());
|
||||
|
||||
Neuron n = new SimplePerceptron(syns, bias, new Linear());
|
||||
GradientDescentTraining st = new GradientDescentTraining();
|
||||
st.train(n, 0.0003F, dataSet);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user