package com.naaturel.ANN.implementation.training;

import com.naaturel.ANN.domain.abstraction.AlgorithmStep;
import com.naaturel.ANN.domain.abstraction.Model;
import com.naaturel.ANN.domain.abstraction.Trainer;
import com.naaturel.ANN.domain.model.training.TrainingPipeline;
import com.naaturel.ANN.implementation.multiLayers.GradientBackpropagationContext;
import com.naaturel.ANN.implementation.multiLayers.GradientBackpropagationStep;
import com.naaturel.ANN.implementation.simplePerceptron.SimpleDeltaStep;
import com.naaturel.ANN.implementation.simplePerceptron.SimplePredictionStep;
import com.naaturel.ANN.infrastructure.dataset.DataSet;

import java.util.List;


public class GradientBackpropagationTraining implements Trainer {
    @Override
    public void train(Model model, DataSet dataset) {
        GradientBackpropagationContext context = new GradientBackpropagationContext();
        context.dataset = dataset;
        context.model = model;
        context.learningRate = 0.001F;

        List<AlgorithmStep> steps = List.of(
                new SimplePredictionStep(context),
                new SimpleDeltaStep(context),
                new GradientBackpropagationStep(context)
        );

        new TrainingPipeline(steps)
                .stopCondition(ctx -> false)
                .withVerbose(true)
                .run(context);

    }
}
