private void LoadFromXMLButton_Click(object sender, RoutedEventArgs e) { if (mainWindow.neuralNetwork != null) { SaveWarning warning = new SaveWarning(); warning.ShowDialog(); if (warning.OverrideNetwork) { OpenFileDialog file = new OpenFileDialog(); file.CheckFileExists = true; file.Multiselect = false; file.Filter = "XML (.xml)|*.xml"; file.ShowDialog(); mainWindow.neuralNetwork = NeuralNetwork.LoadNetworkFromXML(file.FileName); } } else { OpenFileDialog file = new OpenFileDialog(); file.CheckFileExists = true; file.Multiselect = false; file.Filter = "XML (.xml)|*.xml"; file.ShowDialog(); mainWindow.neuralNetwork = NeuralNetwork.LoadNetworkFromXML(file.FileName); } }
} // constructor public InferenceSaver Execute() { if (this.requestID <= 0) { throw new InferenceSaverWrongRequestIDAlert(this.requestID, Log); } if (this.response == null) { throw new InferenceSaverNoDataAlert(this.requestID, Log); } if (Executed) { Log.Alert( "Inference saver({0}, '{1}') has already been executed.", this.requestID, this.response.ToShortString() ); return(this); } // if Executed = true; Log.Debug( "Executing inference saver({0}, '{1}')...", this.requestID, this.response.ToShortString() ); ConnectionWrapper con = DB.GetPersistent(); con.BeginTransaction(); try { new SaveRawResponse(this.requestID, this.response, DB, Log).ExecuteNonQuery(con); ResponseID = new SaveResponse( this.requestID, this.response, this.bucketRepo, this.timeoutSourceRepo, DB, Log ).Execute(con); if (this.response.Parsed.HasInference()) { var map = new SortedDictionary <ModelNames, long>(); var saveMo = new SaveModelOutput(ResponseID, this.response, DB, Log); if (saveMo.HasValidParameters()) { saveMo.ForEachRowSafe(con, sr => { long id = sr["ModelOutputID"]; ModelNames name = (ModelNames)(int)(long)sr["ModelID"]; map[name] = id; }); var saveEf = new SaveEncodingFailure(map, this.response, DB, Log); if (saveEf.HasValidParameters()) // invalid if e.g. no failures { saveEf.ExecuteNonQuery(con); } var saveMi = new SaveMissingColumn(map, this.response, DB, Log); if (saveMi.HasValidParameters()) // invalid if e.g. no missing columns { saveMi.ExecuteNonQuery(con); } var saveOr = new SaveOutputRatio(map, this.response, DB, Log); if (saveOr.HasValidParameters()) // invalid if e.g. no output ratio { saveOr.ExecuteNonQuery(con); } var saveW = new SaveWarning(map, this.response, DB, Log); if (saveW.HasValidParameters()) // invalid if e.g. no output ratio { saveW.ExecuteNonQuery(con); } } // if } // if var saveEtl = new SaveEtlData(ResponseID, this.response, this.etlCodeRepo, DB, Log); if (saveEtl.HasValidParameters()) // invalid if e.g. no ETL data { saveEtl.Execute(con); } new SaveCustomerHistory(ResponseID, DB, Log).ExecuteNonQuery(con); con.Commit(); } catch (Exception e) { con.Rollback(); Log.Warn( "Executing inference saver({0}, '{1}') failed because of exception: '{2}'.", this.requestID, this.response.ToShortString(), e.Message ); throw; } // try Log.Debug( "Executing inference saver({0}, '{1}') complete, response ID is {2}.", this.requestID, this.response.ToShortString(), ResponseID ); return(this); } // Execute
private void CreateNetworkButton_Click(object sender, RoutedEventArgs e) { //check if learning rate is set double learningRate; if (!Double.TryParse(LearningRateTextBox.Text, out learningRate)) { consoleTextBox.AppendText("Learning rate must be set and must be in a correct format (x,xxx) ! \n"); return; } for (int lay = 1; lay < layerDisplay.Items.Count; lay++) { if ((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons == 0) { consoleTextBox.AppendText("Network´s layer cant have 0 neurons ! \n"); return; } } neuralNetwork = window.neuralNetwork; SaveWarning saveWarning; //if there allready is a network, ask user to save it if (neuralNetwork != null) { saveWarning = new SaveWarning(); saveWarning.ShowDialog(); if (saveWarning.OverrideNetwork) { List <int> layers = new List <int>(); List <ActivationFunctions> activationFunctions = new List <ActivationFunctions>(); for (int lay = 1; lay < layerDisplay.Items.Count; lay++) { layers.Add((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons); activationFunctions.Add((ActivationFunctions)Enum.Parse(typeof(ActivationFunctions), (layerDisplay.Items[lay] as NetworkLayerDescriptor).selectedIndex.ToString())); } window.neuralNetwork = new NeuralNetwork(layers.ToArray(), learningRate, activationFunctions); this.neuralNetwork = window.neuralNetwork; consoleTextBox.AppendText("Network succesfully created ! \n"); } else { consoleTextBox.AppendText("Creation canceled \n"); } } //if there is no network, create a new one else { List <int> layers = new List <int>(); List <ActivationFunctions> activationFunctions = new List <ActivationFunctions>(); for (int lay = 1; lay < layerDisplay.Items.Count; lay++) { layers.Add((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons); activationFunctions.Add((ActivationFunctions)Enum.Parse(typeof(ActivationFunctions), (layerDisplay.Items[lay] as NetworkLayerDescriptor).selectedIndex.ToString())); } window.neuralNetwork = new NeuralNetwork(layers.ToArray(), learningRate, activationFunctions); this.neuralNetwork = window.neuralNetwork; consoleTextBox.AppendText("Network succesfully created ! \n"); } }