public static BasicMLDataSet GetSet <T>(this ILearningScenario <T> scenario, IList <T> dataSource) { double[][] input = scenario.InputParams.GetValues(dataSource); double[][] ideal = scenario.OutputParams.GetValues(dataSource); return(new BasicMLDataSet(input, ideal)); }
public static void Compute <T>(BasicNetwork network, ILearningScenario <T> scenario, IList <T> dataSource) { var computingSet = scenario.GetSet(dataSource); foreach (var item in computingSet) { var output = network.Compute(item.Input); Console.WriteLine($"Input: {item.Input[0]}, {item.Input[1]} Ideal: {item.Ideal[0]} Actual: {output[0]}"); } }
public static BasicNetwork Train <T>(ILearningScenario <T> scenario, IList <T> dataSource, BasicNetwork network = null) { if (network == null) { network = NeuralNetwork .CreateNetwork(scenario.InputParams.Count, scenario.OutputParams.Count); } BasicMLDataSet trainingSet = scenario.GetSet(dataSource); var training = GetTraining(network, trainingSet); int epoch = 1; do { training.Iteration(); Debug.WriteLine($"Iteration No: {epoch++}, Error: {training.Error}"); }while (training.Error > scenario.MaxError || epoch < scenario.MaxIterations); return(network); }