public async void LoadTrainFile(string fileName, QueryDataFormat dataFormat, TaskProgressVM taskVM = null) { TrainDatas.Clear(); switch (dataFormat) { case QueryDataFormat.BlackMNIST28x28: var mnistDatas = await _fileService.ReadFromFileAsync(fileName, new CsvMNISTFileReadStrategy()); if (taskVM != null) { taskVM.EndValue = mnistDatas.Count(); } foreach (var data in mnistDatas) { var dataModel = new QueryDataModel(); dataModel.Marker = data.Marker.ToString(); dataModel.InputValues = (from v in data.PixelsValues select(float) v).ToArray(); TrainDatas.Add(dataModel); if (taskVM != null) { taskVM.Value++; } } break; } }
public static void Init() { try { Reset(); foreach (string str in System.IO.Directory.GetDirectories(Application.StartupPath + "\\data\\trains\\resources")) { string[] l = System.IO.File.ReadAllLines(str + @"\data.xml", System.Text.Encoding.Default); if (l[0] == @"<locomotive>") { Locomotive loc = new Locomotive(); loc.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1)); Locomotives.Add(loc); continue; } else if (l[0] == @"<coach>") { Coach car = new Coach(); car.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1)); Coachs.Add(car); continue; } else if (l[0] == @"<enginecoach>") { EngineCoach lc = new EngineCoach(); lc.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1)); EngineCoachs.Add(lc); continue; } } foreach (string str in System.IO.Directory.GetDirectories(".\\data\\trains\\datas")) { TrainData train = new TrainData(); train.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1)); TrainDatas.Add(train); } } catch (Exception e) { Environment.ReportError(e, AccessManager.AccessKey); } }