public static extern void EndAndRunTestEpoch(IntPtr hrlenet, ref TrainInfo trainInfo);
public static extern void TrainOneEpoch(IntPtr hrlenet, ref TrainInfo trainInfo);
public static extern void EndAndRunTrainEpoch(IntPtr hrlenet, ref TrainInfo trainInfo, int epochCount = 1);
//按钮:查看详细信息 private void ViewDetails(object sender, RoutedEventArgs e) { //查看征状详细信息 if (is_signinformationrecord.IsChecked == true) { ViewSymptomInformation viewSymptomInformation = new ViewSymptomInformation { Owner = Window.GetWindow(this), ShowActivated = true, ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterScreen }; List <TrainInfo> list = new List <TrainInfo>(); TrainInfo trainInfo = new TrainInfo { Gmt_Create = new DateTime(2012, 01, 02) }; list.Add(trainInfo); Console.WriteLine(trainInfo.Gmt_Create); list.Add(trainInfo); if (record.Content == null) { MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择症状信息再进行操作!", "Please Select A Symptom Info!")); return; } DataGrid dataGrid = ((SignInformationRecord_Frame)record.Content).SignInformationRecord; SymptomInfoDTO symptomInfoDto = (SymptomInfoDTO)dataGrid.SelectedItem; User user = (User)UsersInfo.SelectedItem; if (user == null) { MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!")); return; } if (symptomInfoDto == null) { MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择症状信息再进行操作!", "Please Select A Symptom Info!")); return; } Dictionary <string, Object> dictionary = new Dictionary <string, object>(); dictionary.Add("user", user); dictionary.Add("symptomInfoDto", symptomInfoDto); viewSymptomInformation.DataContext = dictionary; viewSymptomInformation.ShowDialog(); } //打开训练详细信息 else if (is_trainingrecord.IsChecked == true) { ViewTrainingResults viewTrainingResults = new ViewTrainingResults { Owner = Window.GetWindow(this), ShowActivated = true, ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterScreen }; Object o = record.Content; TrainDTO trainDto = null; User user = (User)UsersInfo.SelectedItem; if (o is TrainingRecord_Frame) { TrainingRecord_Frame trainingRecordFrame = (TrainingRecord_Frame)o; int index = trainingRecordFrame.TabControl1.SelectedIndex; switch (index) { case 0: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord1.SelectedItem; break; case 1: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord2.SelectedItem; break; case 2: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord3.SelectedItem; break; case 3: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord4.SelectedItem; break; case 4: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord5.SelectedItem; break; case 5: trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord6.SelectedItem; break; } } if (user == null) { MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!")); return; } if (trainDto == null) {//判断是否选择了训练信息 MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择训练信息再进行操作!", "Please Select A Train Info!")); return; } Dictionary <string, Object> dic = new Dictionary <string, object>(); dic.Add("user", user); dic.Add("trainDto", trainDto); viewTrainingResults.DataContext = dic; viewTrainingResults.ShowDialog(); } //打开体力评价详细信息 else if (is_physicalevaluation.IsChecked == true) { ViewManualMvaluation viewManualMvaluation = new ViewManualMvaluation { Owner = Window.GetWindow(this), ShowActivated = true, ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterScreen }; Object o = record.Content; PhysicaleDTO physicaleDto = null; User user = (User)UsersInfo.SelectedItem; if (o is PhysicaleValuation_Frame) { PhysicaleValuation_Frame physicaleValuationFrame = (PhysicaleValuation_Frame)o; physicaleDto = (PhysicaleDTO)physicaleValuationFrame.PhysicaleValuation.SelectedItem; } if (user == null) { MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!")); return; } if (physicaleDto == null) {//判断是否选择了训练信息 MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择体力评价再进行操作!", "Please Select A Physical Evalution!")); return; } Dictionary <string, Object> dic = new Dictionary <string, object>(); dic.Add("user", user); dic.Add("physicaleDto", physicaleDto); viewManualMvaluation.DataContext = dic; viewManualMvaluation.ShowDialog(); } }
public virtual TrainInfo TrainBatch(IDataset ds, IDataset ts, int epochs) { TrainInfo trInfo = new TrainInfo(); bool first = true; Floatarray v = new Floatarray(); // Send Train Dataset to Lenet for (int i = 0; i < ds.nSamples(); i++) { ds.Input(v, i); if (v.Rank() == 1) { v.Reshape(csize, csize, 0, 0); } StdInput linput = new StdInput(v); try { if (first) { first = false; //StartRedirectStdout(); // start redirect cout to string buffer BeginTrainEpoch(HrLenet, linput.Height, linput.Width, ds.nSamples(), ts.nSamples()); // init train } if (C2i.ContainsKey(ds.Cls(i))) { AddSampleToTrainOfEpoch(HrLenet, linput.GetDataBuffer(), linput.Length, C2i[ds.Cls(i)]); } else { Global.Debugf("error", "class '{0}' is not contained in the char list", (char)ds.Cls(i)); } } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) { Global.Debugf("error", sbout.ToString() + "\r\nException in AddSampleToTrainOfEpoch"); } throw new Exception("Exception in AddSampleToTrainOfEpoch\r\n" + e.Message); } } // Send Test Dataset to Lenet for (int i = 0; i < ts.nSamples(); i++) { ts.Input(v, i); if (v.Rank() == 1) { v.Reshape(csize, csize, 0, 0); } StdInput linput = new StdInput(v); try { if (C2i.ContainsKey(ts.Cls(i))) { AddSampleToTestOfEpoch(HrLenet, linput.GetDataBuffer(), linput.Length, C2i[ts.Cls(i)]); } } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) { Global.Debugf("error", sbout.ToString() + "\r\nException in AddSampleToTestOfEpoch"); } throw new Exception("Exception in AddSampleToTestOfEpoch\r\n" + e.Message); } } // debug save mnist //SaveTrainMnist(HrLenet, "debug-images-idx3-ubyte", "debug-labels-idx1-ubyte"); // do train epochs for (int epoch = 0; epoch < epochs; epoch++) { trInfo = new TrainInfo(); try { DateTime startDate = DateTime.Now; EndAndRunTrainEpoch(HrLenet, ref trInfo); // do train one epoch // show train info Global.Debugf("info", String.Format("|{0,7}| Energy:{1:0.#####} Correct:{2:0.00#%} Errors:{3:0.00#%} Count:{4} ", trInfo.age, trInfo.energy, (trInfo.correct / (float)trInfo.size), (trInfo.error / (float)trInfo.size), trInfo.size)); Global.Debugf("info", String.Format(" TEST Energy={0:0.#####} Correct={1:0.00#%} Errors={2:0.00#%} Count={3} ", trInfo.tenergy, (trInfo.tcorrect / (float)trInfo.tsize), (trInfo.terror / (float)trInfo.tsize), trInfo.tsize)); TimeSpan spanTrain = DateTime.Now - startDate; Global.Debugf("info", String.Format(" training time: {0} minutes, {1} seconds", (int)spanTrain.TotalMinutes, spanTrain.Seconds)); // get dll stdout messages GetStdout(sbout); if (sbout.Length > 0) { Console.Write(sbout.ToString()); } } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) { Global.Debugf("error", sbout.ToString() + "\r\nException in EndAndRunTrainEpoch"); } throw new Exception("Exception in EndAndRunTrainEpoch\r\n" + e.Message); } } return(trInfo); }
public void ScheduleTrainNotification(TrainInfo train) { var notifyTime = train.ArrivalTime.Subtract(Config.TimeToReachStation); CrossLocalNotifications.Current.Show("Time to go!", $"There's a train coming into {train.Stationfullname} at {train.Exparrival} heading {train.Direction}. If you go now you should make it.", 1, notifyTime); }
public IAsyncResult BeginReciveTrainInfo(TrainInfo info, AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public ActionResult <Guid> CreateTrain([FromBody] TrainInfo train) { return(_trainService.CreateTrain(train)); }
public virtual TrainInfo TrainBatch(IDataset ds, IDataset ts, int epochs) { TrainInfo trInfo = new TrainInfo(); bool first = true; Floatarray v = new Floatarray(); // Send Train Dataset to Lenet for (int i = 0; i < ds.nSamples(); i++) { ds.Input(v, i); if (v.Rank() == 1) v.Reshape(csize, csize, 0, 0); StdInput linput = new StdInput(v); try { if (first) { first = false; //StartRedirectStdout(); // start redirect cout to string buffer BeginTrainEpoch(HrLenet, linput.Height, linput.Width, ds.nSamples(), ts.nSamples()); // init train } if (C2i.ContainsKey(ds.Cls(i))) AddSampleToTrainOfEpoch(HrLenet, linput.GetDataBuffer(), linput.Length, C2i[ds.Cls(i)]); else Global.Debugf("error", "class '{0}' is not contained in the char list", (char)ds.Cls(i)); } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) Global.Debugf("error", sbout.ToString() + "\r\nException in AddSampleToTrainOfEpoch"); throw new Exception("Exception in AddSampleToTrainOfEpoch\r\n" + e.Message); } } // Send Test Dataset to Lenet for (int i = 0; i < ts.nSamples(); i++) { ts.Input(v, i); if (v.Rank() == 1) v.Reshape(csize, csize, 0, 0); StdInput linput = new StdInput(v); try { if (C2i.ContainsKey(ts.Cls(i))) AddSampleToTestOfEpoch(HrLenet, linput.GetDataBuffer(), linput.Length, C2i[ts.Cls(i)]); } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) Global.Debugf("error", sbout.ToString() + "\r\nException in AddSampleToTestOfEpoch"); throw new Exception("Exception in AddSampleToTestOfEpoch\r\n" + e.Message); } } // debug save mnist //SaveTrainMnist(HrLenet, "debug-images-idx3-ubyte", "debug-labels-idx1-ubyte"); // do train epochs for (int epoch = 0; epoch < epochs; epoch++) { trInfo = new TrainInfo(); try { DateTime startDate = DateTime.Now; EndAndRunTrainEpoch(HrLenet, ref trInfo); // do train one epoch // show train info Global.Debugf("info", String.Format("|{0,7}| Energy:{1:0.#####} Correct:{2:0.00#%} Errors:{3:0.00#%} Count:{4} ", trInfo.age, trInfo.energy, (trInfo.correct / (float)trInfo.size), (trInfo.error / (float)trInfo.size), trInfo.size) ); Global.Debugf("info", String.Format(" TEST Energy={0:0.#####} Correct={1:0.00#%} Errors={2:0.00#%} Count={3} ", trInfo.tenergy, (trInfo.tcorrect / (float)trInfo.tsize), (trInfo.terror / (float)trInfo.tsize), trInfo.tsize)); TimeSpan spanTrain = DateTime.Now - startDate; Global.Debugf("info", String.Format(" training time: {0} minutes, {1} seconds", (int)spanTrain.TotalMinutes, spanTrain.Seconds)); // get dll stdout messages GetStdout(sbout); if (sbout.Length > 0) Console.Write(sbout.ToString()); } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) Global.Debugf("error", sbout.ToString() + "\r\nException in EndAndRunTrainEpoch"); throw new Exception("Exception in EndAndRunTrainEpoch\r\n" + e.Message); } } return trInfo; }
public TrainInfo TestDense(IDataset ts) { TrainInfo trInfo = new TrainInfo(); bool first = true; Floatarray v = new Floatarray(); // Send Test Dataset to Lenet for (int i = 0; i < ts.nSamples(); i++) { ts.Input(v, i); if (v.Rank() == 1) v.Reshape(csize, csize, 0, 0); StdInput linput = new StdInput(v); if (first) { first = false; BeginTestEpoch(HrLenet, linput.Height, linput.Width, ts.nSamples()); // init test } try { if (C2i.ContainsKey(ts.Cls(i))) AddSampleToTestOfEpoch(HrLenet, linput.GetDataBuffer(), linput.Length, C2i[ts.Cls(i)]); } catch (Exception e) { GetStdout(sbout); // get train messages if (sbout.Length > 0) Global.Debugf("error", sbout.ToString() + "\r\nException in AddSampleToTestOfEpoch"); throw new Exception("Exception in AddSampleToTestOfEpoch\r\n" + e.Message); } } // do test one epoch try { EndAndRunTestEpoch(HrLenet, ref trInfo); } catch (Exception e) { GetStdout(sbout); // get test messages if (sbout.Length > 0) Global.Debugf("error", sbout.ToString() + "\r\nException in EndAndRunTestEpoch"); throw new Exception("Exception in EndAndRunTestEpoch\r\n" + e.Message); } return trInfo; }
} public void NextPage_Buttom() { NextPage(Convert.ToInt32(route.Position) - Convert.ToInt32(route.Offset) - 1); } public void ParseDirectory(Label l_top) { string path = getZusiPath(); if (path.IndexOf("\\Temp") < 0) path += @"\Temp"; // Create a reference to the current directory. DirectoryInfo di = new DirectoryInfo(path); // Create an array representing the files in the current directory. FileInfo[] fi = null; try { fi = di.GetFiles(); } catch(Exception){} if (fi == null) { MessageBox.Show("Keine Züge gefunden!", "Keine Züge", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } train_list = new Hashtable(); int counter = 0; foreach (FileInfo fiTemp in fi) { counter++; //fiTemp.Name if (fiTemp.Extension != ".txt") continue; // kein zusatzverkehr if (fiTemp.Name.ToLower().IndexOf("zusatz") > -1) continue; // kein dekoverkehr if (fiTemp.Name.ToLower().IndexOf("deko") > -1) continue; // kein dummy if (fiTemp.Name.ToLower().IndexOf("dummy") > -1) continue; // kein abstellung if (fiTemp.Name.ToLower().IndexOf("abstell") > -1) continue; // keine autos if (fiTemp.Name.ToLower().IndexOf("auto") > -1) continue; // if (fiTemp.Name.ToLower().IndexOf("aktuellerzug") > -1) continue; Application.DoEvents(); l_top.Text = "Laden ("+ counter.ToString()+" von " + fi.Length.ToString()+ ")"; TrainInfo ti = new TrainInfo(fiTemp.Name, fiTemp.DirectoryName, XMLConf.SearchForDepAndArr); Application.DoEvents(); if (ti.Number == "") continue; try
/// <summary> /// 保存训练信息 /// DevicePrescription /// </summary> /// <param name="trainInfo"></param> /// <param name="devicePrescriptions"></param> public void SaveTraininfo(object siId, TrainInfo trainInfo, List <NewDevicePrescription> devicePrescriptions) { using (TransactionScope ts = new TransactionScope()) //使整个代码块成为事务性代码 { TrainInfo trainInfoFromDB = GetTrainInfoByUserIdAndStatus(trainInfo.FK_User_Id, trainInfo.Status); if (trainInfoFromDB != null) { switch (trainInfo.Status) { case (int)TrainInfoStatus.Save: //如果保存处方,删除原来的记录和关联的处方 trainInfoDao.DeleteByPrimaryKey(trainInfoFromDB); devicePrescriptionDao.DeleteByTiId(trainInfoFromDB.Pk_TI_Id); break; case (int)TrainInfoStatus.Normal: //如果是写卡后的插入,废弃原来的记录 trainInfoDao.UpdateStatusByUserId(trainInfo.FK_User_Id); break; case (int)TrainInfoStatus.Temp: //如果是暂存状态的数据,废弃之前的该用户的暂存训练信息。在此处并不废弃已经有的nomal状态的信息,写卡成功了,才会废弃。 trainInfoDao.AbandonAllTempTrainInfo(trainInfo.FK_User_Id); break; } } //插入训练信息表 int tiId = (int)trainInfoDao.Insert(trainInfo); //插入上传表 uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 0)); //插入症状信息,如果有症状信息的话 if (trainInfo.Status == (int)TrainInfoStatus.Normal && siId != null) { //如果是写卡,并且选了症状记录,改变症状表外键关联 var symptomInfo = symptomInfoDao.Load((int)siId); symptomInfo.Fk_TI_Id = tiId; symptomInfoDao.UpdateByPrimaryKey(symptomInfo); //插入至上传表 uploadManagementDao.Insert(new UploadManagement(symptomInfo.Pk_SI_Id, "bdl_symptominfo", 1)); } int dpId; //插入设备处方 if (devicePrescriptions != null) { foreach (NewDevicePrescription devicePrescription in devicePrescriptions) { devicePrescription.Fk_ti_id = tiId; dpId = (int)devicePrescriptionDao.Insert(devicePrescription); //插入至上传表 uploadManagementDao.Insert(new UploadManagement(dpId, "bdl_deviceprescription", 0)); } } ts.Complete(); } }
public void UpdateTrain([FromBody] TrainInfo train, [FromRoute] Guid trainId) { _trainService.UpdateTrain(trainId, train); }
private void LoadBoard(int players) { if (_imageBoard !.PrivateList.Count == 0) { throw new BasicBlankException("Sorry; there are no items on the private list. Run FirstLoad first before loading the board"); } if (TrainList.Count > 0) { throw new BasicBlankException("There are already items on the train list"); } if (Self > 7) { throw new BasicBlankException("The self player has to be between 1 and 7"); } CustomBasicList <int> newList; if (players == 2) { newList = new CustomBasicList <int>() { 1, 3, 6 }; } else if (players == 3) { newList = new CustomBasicList <int>() { 1, 3, 6, 8 }; } else if (players == 4) { newList = new CustomBasicList <int>() { 1, 2, 3, 6, 8 }; } else if (players == 5) { newList = new CustomBasicList <int>(); for (var x = 1; x <= 5; x++) { newList.Add(x); } newList.Add(8); } else if (players == 6) { newList = new CustomBasicList <int>(); for (var x = 1; x <= 6; x++) { newList.Add(x); } newList.Add(8); } else if (players == 7) { newList = GetIntegerList(1, 8); } else { throw new BasicBlankException("Sorry; the new list does not match. Find out what happened"); } for (var x = 1; x <= players + 1; x++) { TrainInfo thisTrain = new TrainInfo(); thisTrain.Index = newList[x - 1]; if (x == players + 1) { thisTrain.TrainUp = true; thisTrain.IsPublic = true; } TrainList.Add(thisTrain); } RepaintBoard(); }
static void Main(string[] args) { TrainInfo ti = ProcessXml(@"XMLFile1.xml", 1); }