public void LoadValuesFor(NeuralNetwork neuralNetwork) { var firstLayerWeights = new ValueList<double>(); var secondLayerWeights = new ValueList<double>(); var secondLayerThresholds = new ValueList<double>(); var thirdLayerThresholds = new ValueList<double>(); try { var connection = new NpgsqlConnection(ConnectionString); connection.Open(); var command = new NpgsqlCommand { Connection = connection }; command.CommandText = "SELECT weight FROM pr4_weights_layer1 ORDER BY id ASC"; var reader = command.ExecuteReader(); while (reader.Read()) firstLayerWeights.Add(reader.GetDouble(0)); reader.Close(); command.CommandText = "SELECT weight FROM pr4_weights_layer2 ORDER BY id ASC"; reader = command.ExecuteReader(); while (reader.Read()) secondLayerWeights.Add(reader.GetDouble(0)); reader.Close(); command.CommandText = "SELECT threshold FROM pr4_thresholds_layer2 ORDER BY id ASC"; reader = command.ExecuteReader(); while (reader.Read()) secondLayerThresholds.Add(reader.GetDouble(0)); reader.Close(); command.CommandText = "SELECT threshold FROM pr4_thresholds_layer3 ORDER BY id ASC"; reader = command.ExecuteReader(); while (reader.Read()) thirdLayerThresholds.Add(reader.GetDouble(0)); neuralNetwork.SetWeightsForLayer(1, firstLayerWeights); neuralNetwork.SetWeightsForLayer(2, secondLayerWeights); neuralNetwork.SetThresholdsForLayer(2, secondLayerThresholds); neuralNetwork.SetThresholdsForLayer(3, thirdLayerThresholds); } catch (Exception) { Console.WriteLine("There was a problem loading values from the database."); throw; } }