public NeuralNetworkBuilder Layer(int numOfNeurons, FunctionApplier functionApplier, double learningRate = 0.01) { _layers.Add(new Layer() { Applier = functionApplier, NeuronsNumber = numOfNeurons, LearningRate = learningRate }); return(this); }
public static trainerParams BuildNet(FlowLayoutPanel layers, FileDialog LoadData_dlg, Result r, Telerik.WinControls.UI.RadDiagram radDiagram1) { Training.Trainer trainer = new Training.Trainer(); NeuralNetworkBuilder b = new NeuralNetworkBuilder(); L_ctrl_mat temp; int neuronsnumber; IActivatorFunction AF = null; FunctionApplier functionApplier = new FunctionApplier(); foreach (var layer in layers.Controls) { temp = layer as L_ctrl_mat; neuronsnumber = Convert.ToInt16(temp.NN_drpdn.Value); if (ActivatorFunctions.FunctionName.SIGMOID.ToString() == temp.AF_drpdn.SelectedItem.Text) { AF = new SigmoidFunction(); imgs.Add(Resources.Layer__Sigmoid); } if (ActivatorFunctions.FunctionName.TANH.ToString() == temp.AF_drpdn.SelectedItem.Text) { AF = new TanhFunction(); imgs.Add(Resources.Layer_Tan_H); } functionApplier.ActivatorFunction = AF; b.Layer(neuronsnumber, functionApplier, (double)temp.Lr_drpdn.Value); } NeuralNetwork.NeuralNetwork nn = b.Build(); string FileName = LoadData_dlg.FileName; var tuples = DataReader.DataReader.Instance.ReadFromFile(FileName); var inputs = tuples.Item1; var outputs = tuples.Item2; // StaticDivider Divider = new StaticDivider(.6,.3); //var temp2 = Divider.Divide(inputs, outputs); //ActivatorFunctions.FunctionName applier ; //// test case (should belong to the second class = [0 1 0]) //var tt = nn.ForwardInput(Vector<double>.Build.DenseOfArray(new double[] { 5.5, 2.5, 4.0, 1.3 })); Params = new trainerParams(); Params.nn = nn; Params.Tuple = tuples; NetGraph(nn, radDiagram1); return(Params); }