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.training.GradientBackpropagationTraining;
import com.naaturel.ANN.infrastructure.dataset.DataSet;
import com.naaturel.ANN.infrastructure.dataset.DatasetExtractor;
import com.naaturel.ANN.domain.model.neuron.*;

import java.util.*;

public class Main {

    public static void main(String[] args){

        int nbrInput = 2;
        int nbrClass = 3;

        int nbrLayers = 2;

        DataSet dataset = new DatasetExtractor()
                .extract("C:/Users/Laurent/Desktop/ANN-framework/src/main/resources/assets/table_3_1.csv", nbrClass);

        List<Layer> layers = new ArrayList<>();
        for(int i = 0; i < nbrLayers; i++){

            List<Neuron> neurons = new ArrayList<>();
            for (int j=0; j < nbrClass; j++){

                List<Synapse> syns = new ArrayList<>();
                for (int k=0; k < nbrInput; k++){
                    syns.add(new Synapse(new Input(0), new Weight(0)));
                }

                Bias bias =  new Bias(new Weight(0));

                Neuron n = new Neuron(syns, bias, new Sigmoid(1));
                neurons.add(n);
            }
            Layer layer = new Layer(neurons);
            layers.add(layer);
        }
        FullyConnectedNetwork network = new FullyConnectedNetwork(layers);

        Trainer trainer = new GradientBackpropagationTraining();
        trainer.train(network, dataset);

    }
}
