Implement multi layer
This commit is contained in:
@@ -3,6 +3,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.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.DatasetExtractor;
|
||||
@@ -14,33 +15,36 @@ public class Main {
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
int nbrInput = 2;
|
||||
int nbrClass = 3;
|
||||
int nbrInput = 25;
|
||||
int nbrClass = 4;
|
||||
|
||||
int nbrLayers = 2;
|
||||
int[] neuronPerLayer = new int[]{10, nbrClass};
|
||||
|
||||
DataSet dataset = new DatasetExtractor()
|
||||
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_3_1.csv", nbrClass);
|
||||
.extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_3_5.csv", nbrClass);
|
||||
|
||||
List<Layer> layers = new ArrayList<>();
|
||||
for(int i = 0; i < nbrLayers; i++){
|
||||
for (int i = 0; i < neuronPerLayer.length; i++){
|
||||
|
||||
List<Neuron> neurons = new ArrayList<>();
|
||||
for (int j=0; j < nbrClass; j++){
|
||||
for (int j = 0; j < neuronPerLayer[i]; j++){
|
||||
|
||||
int nbrSyn = i == 0 ? nbrInput: neuronPerLayer[i-1];
|
||||
|
||||
List<Synapse> syns = new ArrayList<>();
|
||||
for (int k=0; k < nbrInput; k++){
|
||||
syns.add(new Synapse(new Input(0), new Weight(0)));
|
||||
for (int k=0; k < nbrSyn; k++){
|
||||
syns.add(new Synapse(new Input(0), new Weight()));
|
||||
}
|
||||
|
||||
Bias bias = new Bias(new Weight(0));
|
||||
Bias bias = new Bias(new Weight());
|
||||
|
||||
Neuron n = new Neuron(syns, bias, new Sigmoid(1));
|
||||
Neuron n = new Neuron(syns, bias, new TanH());
|
||||
neurons.add(n);
|
||||
}
|
||||
Layer layer = new Layer(neurons);
|
||||
layers.add(layer);
|
||||
}
|
||||
|
||||
FullyConnectedNetwork network = new FullyConnectedNetwork(layers);
|
||||
|
||||
Trainer trainer = new GradientBackpropagationTraining();
|
||||
|
||||
Reference in New Issue
Block a user