public static void GetAllWeidtg() { var tmp = new np4load(@"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4"); var neuralNet = tmp.GetNeuralNetwork(); var w = tmp.GetWeigth(); neuralNet.DecodeFromArray(w); }
private void cbTrainsLog_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbTrainsLog.SelectedItem != null) { InitEvent ie = cbTrainsLog.SelectedItem as InitEvent; //ist<int> ageNum = new List<int>(ie.IterationCount); //int[] ageNum2 = new int[ie.IterationCount]; //Parallel.For(1, ie.IterationCount+1, i => ageNum2[i-1] = i); //for (int i = 1; i <= ie.IterationCount; i++) // ageNum.Add(i); iterations = rep.GetIteration(ie.Sid).OrderBy(x => x.AgeNumber); cbAgeNumber.ItemsSource = iterations; currentXmlNet = new np4load(ie.Path); neuralNetIter = currentXmlNet.GetNeuralNetwork(); trainingData = currentXmlNet.GetTrainingData(); graphIterations = null; testD.ClearAll(); pairDiagram.ClearAll(); } }
public static void TrainNet() { var tmp = new np4load(@"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4"); TrainLogger tLog = TrainLogger.GetTrainLogger(); Dictionary<string, object> dLog = new Dictionary<string, object>(); var stopParam = tmp.GetTrainingStopParams(); int iterCount = 2500;//13943; dLog.Add("event", "init"); dLog.Add("NeuralNetName", "инфаркт_миокарда.np4"); dLog.Add("Path", @"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4"); dLog.Add("Анкета", "Кардиология"); dLog.Add("IterationCount", iterCount); dLog.Add("Time", DateTime.Now); BasicMLDataSet tData = (BasicMLDataSet) tmp.GetTrainingData(); dLog.Add("TrainDataSize", tData.Count); //записать входные данные и проскалированные tLog.WriteEvent(dLog); BasicNetwork neuralNet = tmp.GetNeuralNetwork(); MediatorNsimLinearScale scale = new MediatorNsimLinearScale(); DataProcessorConf dp = tmp.GetDataProcessor(); scale.DataProcessorM(dp); //SearchHashForm search = new SearchHashForm(); //Guid[] gidForm = search.GetGIDForm(tData); BasicMLDataSet tDataScale = scale.ProcessDataSet(tData); IMLTrain trainMetod; switch (tmp.GetNameTrainMetod()) { case "ResilientPropagation": { trainMetod = new ResilientPropagation(neuralNet, tDataScale); break; } default: { trainMetod = new ResilientPropagation(neuralNet, tDataScale); break; } } //trainMetod.Iteration(stopParam.Iterations); trainMetod.Iteration(iterCount); //var arrWeight = neuralNet.DumpWeights().Split(','); //using (FileLogger fl = FileLogger.GetLogger()) //{ // fl.WriteString(neuralNet.DumpWeights()); // for (int i = 0; i < tDataScale.Data.Count; i++)//var item in tDataScale.Data) // { // fl.WriteString("Входной вектор: " + GetString(tData.Data[i].InputArray)); // var res = neuralNet.Compute(tDataScale.Data[i].Input); // fl.WriteString("Результат: " + GetString(res.Data)); // var sRes = scale.RestoreIdealVector(res); // fl.WriteString("Результат востановленный: " + GetString(sRes.Data)); // fl.WriteString("\n"); // } //} trainMetod.FinishTraining(); //int countW = neuralNet.EncodedArrayLength(); //double[] w = new double[countW]; //neuralNet.EncodeToArray(w); Console.WriteLine("!!!"); //for (int i = 0; i < stopParam.Iterations; i++) //{ // trainMetod.Iteration( //} }