public async Task TrainNetworkAsync() { int[] layerSize = CreateLayersSize(); TransferFunction[] tfunc = AddTransferFunctionToLayers(); BackPropagationNetwork bpn = null; NetworkTrainer nt; if (bpn == null) { bpn = new BackPropagationNetwork(layerSize, tfunc); } await FixInputs(); nt = new NetworkTrainer(bpn, _dataSet); Task.Run(() => { nt.MaxError = MaxError; nt.MaxIterations = MaxIterations; nt.NudgeWindow = NudgeWindow; nt.TrainDataSet(); nt.Network.Save(@"tezine.xml"); double[] error = nt.GetErrorHistory(); string[] filedata = new string[error.Length]; for (int i = 0; i < error.Length; i++) { filedata[i] = i.ToString() + " " + error[i].ToString(); } File.WriteAllLines(@"greske.txt", filedata); NetworkTrained?.Invoke(this, "Završeno treniranje."); }); dynamic settings = SetSettingsForProgressReportPopup(); TrainingNetworkReport.Status = "Treniranje mreže..."; TrainingNetworkReport.Progress = 0; TrainingNetworkReport.MaxIterations = MaxIterations; TrainingNetworkReport.Error = 0; WindowManager window = new WindowManager(); window.ShowDialog(new TrainingNetworkProgresBarViewModel(ref _trainingNetworkReport, settings, this, nt)); }
protected virtual void OnNetworkTrained() { NetworkTrained?.Invoke(this, EventArgs.Empty); }