public ExpressionsDialog(ref TrainingDataSet DataSet) { InitializeComponent(); _DataSet = DataSet; ExpressionsDataGrid.ItemsSource = _DataSet.Expression; }
public TrainingDataSetsDialog(ref TrainingDataSet DataSet) { InitializeComponent(); _DataSet = DataSet; TrainingDataGrid.ItemsSource = _DataSet.Training; }
public void PerformEpochAndAssert() { var trainingData = TrainingDataSet.For(inputs, outputs); var errorRate = trainingMethod.PerformSingleEpochProducingErrorRate(trainingData); AssertResultOfTrainingEpoch(errorRate); }
public BatchClassificationDialog(ref Klu klu, ref TrainingDataSet dataSet, ProcessOptions processOptions) { InitializeComponent(); _BackgroundWorker = new BackgroundWorker(); _BackgroundWorker.WorkerReportsProgress = true; _BackgroundWorker.WorkerSupportsCancellation = true; _BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork); _BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); _BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); BrowseButton.IsEnabled = true; CancelButton.IsEnabled = false; ClassifyButton.IsEnabled = false; _DataSet = dataSet; _SelectedFiles = new ArrayList(); _ProcessOptions = processOptions; // We want the images to be as less distorded as possible, so we disable all the overlays. _ProcessOptions.DrawAnthropometricPoints = 0; _ProcessOptions.DrawDetectionTime = 0; _ProcessOptions.DrawFaceRectangle = 0; _ProcessOptions.DrawSearchRectangles = 0; _ProcessOptions.DrawFeaturePoints = 0; _KLU = klu; _FFP = new FaceFeaturePoints(); _TempBitmap = new System.Drawing.Bitmap(10, 10); ExpressionsComboBox.ItemsSource = _DataSet.Expression; ClassifyButton.Content = "Classify"; }
private void DisplayData_Click(object sender, RoutedEventArgs e) { // Get selected if (this.TrainingDataList.SelectedItem == null) { MessageBox.Show("Please select a data set first!"); return; } // Reset View this.TrainingDataSet.Clear(); this.Hypothesis.Clear(); // Assign training data switch (this.TrainingDataList.SelectedIndex) { case 0: this.CurrentTestData = TrainingData.CourseraTs; break; case 1: this.CurrentTestData = TrainingData.TestDataTs; break; case 2: this.CurrentTestData = TrainingData.ExcelTs; break; case 3: this.CurrentTestData = TrainingData.OpenClassRoomTs; break; } // Get training data for (int pointIndex = 0; pointIndex < CurrentTestData.GetLength(0); pointIndex++) { Point point = new Point(CurrentTestData[pointIndex, 0], CurrentTestData[pointIndex, 1]); TrainingDataSet.Add(new ObservablePoint(point.X, point.Y)); Debug.OutPut(point); } // Get iterations int iterations; try { iterations = int.Parse(this.IterationsText.Text); } catch (Exception) { MessageBox.Show("Please enter a correct iteration int!"); return; } // Run new thread with the gradient algorithm ThreadPool.QueueUserWorkItem(o => { MachineLearningCalculator.GradientDescent(this.CurrentTestData, 0, 0, this.Hypothesis, iterations); }); }
public BackPropagationPerformanceComparisonContainer() { var neuralNetworkUnderTest = NeuralNetwork .For(NeuralNetworkContext.MaximumPrecision) .WithInputLayer(neuronCount: 5, activationType: ActivationType.Sigmoid) .WithHiddenLayer(neuronCount: 100, activationType: ActivationType.Sigmoid) .WithHiddenLayer(neuronCount: 70, activationType: ActivationType.TanH) .WithHiddenLayer(neuronCount: 40, activationType: ActivationType.TanH) .WithHiddenLayer(neuronCount: 100, activationType: ActivationType.Sigmoid) .WithOutputLayer(neuronCount: 2, activationType: ActivationType.Sigmoid) .Build(); trainingData = new[] { TrainingDataSet.For(new [] { 0.78, 0.99, 0.67, 0.72, 0.22 }, new [] { 0.12, 0.14 }) }; multiThreadedController = TrainingController.For( BackPropagation .WithConfiguration(neuralNetworkUnderTest, ParallelOptionsExtensions.UnrestrictedMultiThreadedOptions)); singleThreadedController = TrainingController.For( BackPropagation .WithConfiguration(neuralNetworkUnderTest, ParallelOptionsExtensions.SingleThreadedOptions)); }
/// <summary> /// No conversion is done here, but a list of all Expressions is returned. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns>Expressions</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { _TAM = new TableAdapterManager(); _DataSet = new TrainingDataSet(); _TAM.ExpressionTableAdapter = new ExpressionTableAdapter(); _TAM.ExpressionTableAdapter.Fill(_DataSet.Expression); return(_DataSet.Expression); //TableAdapterManager _TAM = new TableAdapterManager(); //TrainingDataSet _DataSet = new TrainingDataSet(); //_TAM.ExpressionTableAdapter = new ExpressionTableAdapter(); //_TAM.ExpressionTableAdapter.Fill(_DataSet.Expression); //ArrayList expressions = new ArrayList(); //for (int i=0; i<_DataSet.Expression.Count; i++) //{ // expressions.Add(_DataSet.Expression[i].Expression); //} //return expressions; } catch (NullReferenceException) { return(null); } }
/// <summary> /// No conversion is done here, but a list of all Expressions is returned. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns>Expressions</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { _TAM = new TableAdapterManager(); _DataSet = new TrainingDataSet(); _TAM.ExpressionTableAdapter = new ExpressionTableAdapter(); _TAM.ExpressionTableAdapter.Fill(_DataSet.Expression); return _DataSet.Expression; //TableAdapterManager _TAM = new TableAdapterManager(); //TrainingDataSet _DataSet = new TrainingDataSet(); //_TAM.ExpressionTableAdapter = new ExpressionTableAdapter(); //_TAM.ExpressionTableAdapter.Fill(_DataSet.Expression); //ArrayList expressions = new ArrayList(); //for (int i=0; i<_DataSet.Expression.Count; i++) //{ // expressions.Add(_DataSet.Expression[i].Expression); //} //return expressions; } catch (NullReferenceException) { return null; } }
public async Task <InvokeResult> UpdateTrainingDataSetManager(TrainingDataSet set, EntityHeader org, EntityHeader user) { await AuthorizeAsync(set, AuthorizeResult.AuthorizeActions.Update, user, org); var result = Validator.Validate(set, Actions.Update); await _repo.UpdateTrainingDataSetsAsync(set); return(result.ToInvokeResult()); }
public async Task <InvokeResult> AddTrainingDataSetManager(TrainingDataSet dataSet, EntityHeader org, EntityHeader user) { ValidationCheck(dataSet, Actions.Create); await AuthorizeAsync(dataSet, AuthorizeResult.AuthorizeActions.Create, user, org); await _repo.AddTrainingDataSetsAsync(dataSet); return(InvokeResult.Success); }
public static TrainingDataSet ToTrainingData(this BankTransaction bankTransaction) { var inputs = bankTransaction.ToNetworkInputData(); var outputs = Enumerable.Repeat(0.0, 2).ToList(); outputs[Convert.ToInt32(bankTransaction.Class)] = 1; return(TrainingDataSet.For(inputs.ToArray(), outputs.ToArray())); }
public static TrainingDataSet TrainingDataFromRow(IrisDataRow row) { var species = Enumerable.Repeat(0.0, 3).ToArray(); species[Convert.ToInt32(row.Species) - 1] = 1.0; return(TrainingDataSet.For( row.PredictionDataPoints, species.ToArray())); }
private static List <TrainingDataSet> GetMyTrainingData() { // 2 tableaux // inputs : double[22][64] // outputs : double[22][3] string filename = BASEFOLDER + "Base.txt"; string[] lines = File.ReadAllLines(filename); // lines va contenir 44 lines int nbSamples = lines.Length / 2; // 22 exemples double[][] inputs = new double[nbSamples][]; double[][] outputs = new double[nbSamples][]; for (int i = 0; i < nbSamples; i++) { inputs[i] = new double[64]; // inputs[i] est de type double[] outputs[i] = new double[3]; // lines[2*i+0] contient la string "0000010101001001001010101010" // lines[2*i+1] contient la string "C" int k = 0; foreach (char c in lines[2 * i]) { if (c == '0') { inputs[i][k] = 0.0; } if (c == '1') { inputs[i][k] = 1.0; } k++; } if (lines[2 * i + 1] == "A") { outputs[i][0] = 1.0; outputs[i][1] = 0.0; outputs[i][2] = 0.0; } if (lines[2 * i + 1] == "B") { outputs[i][0] = 0.0; outputs[i][1] = 1.0; outputs[i][2] = 0.0; } if (lines[2 * i + 1] == "C") { outputs[i][0] = 0.0; outputs[i][1] = 0.0; outputs[i][2] = 1.0; } } return(inputs.Select((input, i) => TrainingDataSet.For(input, outputs[i])).ToList()); }
private static List <TrainingDataSet> GetXorTrainingData() { var inputs = new[] { new[] { 0.0, 0.0 }, new[] { 0.0, 1.0 }, new[] { 1.0, 0.0 }, new[] { 1.0, 1.0 } }; var outputs = new[] { new[] { 0.0 }, new[] { 1.0 }, new[] { 1.0 }, new[] { 0.0 } }; return(inputs.Select((input, i) => TrainingDataSet.For(input, outputs[i])).ToList()); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { TableAdapterManager tam = new TableAdapterManager(); TrainingDataSet dataSet = new TrainingDataSet(); tam.ExpressionTableAdapter = new ExpressionTableAdapter(); tam.ExpressionTableAdapter.Fill(dataSet.Expression); int eoid = System.Convert.ToInt32(value); if (!DBNull.Value.Equals(eoid)) { TrainingDataSet.ExpressionRow row = dataSet.Expression.FindByExpressionOID(eoid); if (!DBNull.Value.Equals(row) && !DBNull.Value.Equals(row.Thumbnail)) { byte[] imageData = row.Thumbnail; if (imageData != null && !DBNull.Value.Equals(imageData)) { byte[] data = (byte[])value; MemoryStream ms = new MemoryStream(data); BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = ms; image.EndInit(); return(image); } } } return(null); } catch (NullReferenceException) { return(null); } catch (System.Data.StrongTypingException) { return(null); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { TableAdapterManager tam = new TableAdapterManager(); TrainingDataSet dataSet = new TrainingDataSet(); tam.ExpressionTableAdapter = new ExpressionTableAdapter(); tam.ExpressionTableAdapter.Fill(dataSet.Expression); return(dataSet.Expression.FindByExpressionOID(System.Convert.ToInt32(value)).Expression); } catch (NullReferenceException) { return(null); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { TableAdapterManager tam = new TableAdapterManager(); TrainingDataSet dataSet = new TrainingDataSet(); tam.ExpressionTableAdapter = new ExpressionTableAdapter(); tam.ExpressionTableAdapter.Fill(dataSet.Expression); int eoid = System.Convert.ToInt32(value); if (!DBNull.Value.Equals(eoid)) { TrainingDataSet.ExpressionRow row = dataSet.Expression.FindByExpressionOID(eoid); if (!DBNull.Value.Equals(row) && !DBNull.Value.Equals(row.Thumbnail)) { byte[] imageData = row.Thumbnail; if (imageData != null && !DBNull.Value.Equals(imageData)) { byte[] data = (byte[])value; MemoryStream ms = new MemoryStream(data); BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = ms; image.EndInit(); return image; } } } return null; } catch (NullReferenceException) { return null; } catch (System.Data.StrongTypingException) { return null; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { TableAdapterManager tam = new TableAdapterManager(); TrainingDataSet dataSet = new TrainingDataSet(); tam.ExpressionTableAdapter = new ExpressionTableAdapter(); tam.ExpressionTableAdapter.Fill(dataSet.Expression); return dataSet.Expression.FindByExpressionOID(System.Convert.ToInt32(value)).Expression; } catch (NullReferenceException) { return null; } }
public async Task Train() { await Task.Run(new Action(() => { Console.WriteLine(); for (int i = 0; i < 50; i++) { Console.WriteLine("Run Epoch {0}", i); Network.IsPreTraining = true; DoEpoch(TrainingDataSet.Take(500)); Network.IsPreTraining = false; DoEpoch(TrainingDataSet); } Console.WriteLine("Complete."); } )); }
public TrainingDialog(ref TrainingDataSet dataSet) { InitializeComponent(); _BackgroundWorker = new BackgroundWorker(); _BackgroundWorker.WorkerReportsProgress = true; _BackgroundWorker.WorkerSupportsCancellation = true; _BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork); _BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); _BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); _DataSet = dataSet; _Chart = new Chart(); windowsFormsHost1.Child = _Chart; _Series = 0; StopButton.IsEnabled = false; _Network = new ActivationNetwork( new SigmoidFunction(), _NumInputNeurons, 9, _NumOutputNeurons ); #region Initialize ANN stuff _ANN = new ANN(); _ANN.NumLayers = 3; _ANN.SetNumNeurons(0, _NumInputNeurons); _ANN.SetNumNeurons(1, 9); _ANN.SetNumNeurons(2, _NumOutputNeurons); // Bind DataGrid to ANN-DataSet now _DataSetANN = new DataSet("HiddenLayer"); _DataSetANN.Tables.Add("HiddenLayerTable"); uint tmp = 9; _DataSetANN.Tables[0].Columns.Add("Neurons", tmp.GetType()); _DataSetANN.Tables[0].Rows.Add(tmp); HiddenLayerDataGrid.DataContext = _DataSetANN.Tables[0]; #endregion }
public BatchClassification(ref Klu klu, ref TrainingDataSet dataSet, ProcessOptions processOptions) { InitializeComponent(); _DataSet = dataSet; _SelectedFiles = new ArrayList(); _ProcessOptions = processOptions; // We want the images to be as less distorded as possible, so we disable all the overlays. _ProcessOptions.DrawAnthropometricPoints = 0; _ProcessOptions.DrawDetectionTime = 0; _ProcessOptions.DrawFaceRectangle = 0; _ProcessOptions.DrawSearchRectangles = 0; _ProcessOptions.DrawFeaturePoints = 0; _KLU = klu; _FFP = new FaceFeaturePoints(); _TempBitmap = new System.Drawing.Bitmap(10, 10); ExpressionsComboBox.ItemsSource = _DataSet.Expression; ClassifyButton.Content = "Classify"; }
public void GenerateTrainingAndTestSets() { TrainingSet = new TrainingDataSet(_dataSet, NumberOfInputs); TestSet = new TestDataSet(_dataSet, NumberOfInputs); }
public static void AddTrainingData(ref TrainingDataSet dataSet, ref FaceFeaturePoints ffp, int expressionOID, ref System.Drawing.Bitmap picture) { // Convert facial coordinates to relative face rectangle coordinates. // We do this because we are not interested in absolute coordinates but in quality of the face. int x = ffp.FaceRectangle.X; int y = ffp.FaceRectangle.Y; int w = ffp.FaceRectangle.Width; int h = ffp.FaceRectangle.Height; // Calculate the eye distance (in relative coordinates float dx = i2r(ffp.RightEye.EyeCenter.X, x, w) - i2r(ffp.LeftEye.EyeCenter.X, x, w); float dy = i2r(ffp.RightEye.EyeCenter.Y, y, h) - i2r(ffp.LeftEye.EyeCenter.Y, y, h); //float dx = i2r(ffp.RightEye.EyeCenter.X - ffp.LeftEye.EyeCenter.X, x, w); //float dy = i2r(ffp.RightEye.EyeCenter.Y - ffp.LeftEye.EyeCenter.Y, y, h); float eyeDist = (float)Math.Sqrt(dx * dx + dy * dy); // Construct thumbnail const int thumbnailWidth = 50; const int thumbnailHeight = 50; System.Drawing.Rectangle faceRect = new System.Drawing.Rectangle(x, y, w, h); System.Drawing.Bitmap faceImg = picture.Clone(faceRect, picture.PixelFormat); System.Drawing.Image.GetThumbnailImageAbort tc = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image thumbnail = faceImg.GetThumbnailImage(thumbnailWidth, thumbnailHeight, tc, IntPtr.Zero); System.IO.MemoryStream ms = new System.IO.MemoryStream(); thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Png); TrainingDataSet.TrainingRow row = dataSet.Training.NewTrainingRow(); row.ExpressionOID = expressionOID; row.LipCornerLeftX = i2r(ffp.Mouth.LipCornerLeft.X, x, w); row.LipCornerLeftY = i2r(ffp.Mouth.LipCornerLeft.Y, y, h); row.LipCornerRightX = i2r(ffp.Mouth.LipCornerRight.X, x, w); row.LipCornerRightY = i2r(ffp.Mouth.LipCornerRight.Y, y, h); row.LipUpLeftX = i2r(ffp.Mouth.LipUpLeft.X, x, w); row.LipUpLeftY = i2r(ffp.Mouth.LipUpLeft.Y, y, h); row.LipUpCenterX = i2r(ffp.Mouth.LipUpCenter.X, x, w); row.LipUpCenterY = i2r(ffp.Mouth.LipUpCenter.Y, y, h); row.LipUpRightX = i2r(ffp.Mouth.LipUpRight.X, x, w); row.LipUpRightY = i2r(ffp.Mouth.LipUpRight.Y, y, h); row.LipUpRightX = i2r(ffp.Mouth.LipBottomLeft.X, x, w); row.LipUpRightY = i2r(ffp.Mouth.LipBottomLeft.Y, y, h); row.LipBottomCenterX = i2r(ffp.Mouth.LipBottomCenter.X, x, w); row.LipBottomCenterY = i2r(ffp.Mouth.LipBottomCenter.Y, y, h); row.LipBottomRightX = i2r(ffp.Mouth.LipBottomRight.X, x, w); row.LipBottomRightY = i2r(ffp.Mouth.LipBottomRight.Y, y, h); row.LipBottomLeftX = i2r(ffp.Mouth.LipBottomLeft.X, x, w); row.LipBottomLeftY = i2r(ffp.Mouth.LipBottomLeft.Y, y, h); row.EyeDistance = eyeDist; row.LeftEyeCenterX = i2r(ffp.LeftEye.EyeCenter.X, x, w); row.LeftEyeCenterY = i2r(ffp.LeftEye.EyeCenter.Y, y, h); row.LeftLidBottomX = i2r(ffp.LeftEye.LidBottomCenter.X, x, w); row.LeftLidBottomY = i2r(ffp.LeftEye.LidBottomCenter.Y, y, h); row.LeftLidCornerLeftX = i2r(ffp.LeftEye.LidCornerLeft.X, x, w); row.LeftLidCornerLeftY = i2r(ffp.LeftEye.LidCornerLeft.Y, y, h); row.LeftLidCornerRightX = i2r(ffp.LeftEye.LidCornerRight.X, x, w); row.LeftLidCornerRightY = i2r(ffp.LeftEye.LidCornerRight.Y, y, h); row.LeftLidUpX = i2r(ffp.LeftEye.LidUpCenter.X, x, w); row.LeftLidUpY = i2r(ffp.LeftEye.LidUpCenter.Y, y, h); row.RightEyeCenterX = i2r(ffp.RightEye.EyeCenter.X, x, w); row.RightEyeCenterY = i2r(ffp.RightEye.EyeCenter.Y, y, h); row.RightLidBottomX = i2r(ffp.RightEye.LidBottomCenter.X, x, w); row.RightLidBottomY = i2r(ffp.RightEye.LidBottomCenter.Y, y, h); row.RightLidCornerLeftX = i2r(ffp.RightEye.LidCornerLeft.X, x, w); row.RightLidCornerLeftY = i2r(ffp.RightEye.LidCornerLeft.Y, y, h); row.RightLidCornerRightX = i2r(ffp.RightEye.LidCornerRight.X, x, w); row.RightLidCornerRightY = i2r(ffp.RightEye.LidCornerRight.Y, y, h); row.RightLidUpX = i2r(ffp.RightEye.LidUpCenter.X, x, w); row.RightLidUpY = i2r(ffp.RightEye.LidUpCenter.Y, y, h); row.MouthCenterX = i2r(ffp.Mouth.MouthCenter.Y, y, h); row.MouthCenterY = i2r(ffp.Mouth.MouthCenter.Y, y, h); row.Thumbnail = ms.ToArray(); dataSet.Training.AddTrainingRow(row); }
/// <summary> /// The main entry point for this window. /// </summary> public MainWindow() { InitializeComponent(); Console.WriteLine("Loc: " + System.Reflection.Assembly.GetExecutingAssembly().Location); try { _CurrentImagePathIndex = 0; _ImagePathArray = new ArrayList(); _ProcessOptions = new ProcessOptions(); _FFP = new FaceFeaturePoints(); _ProcessOptions.DoEyeProcessing = 1; _ProcessOptions.DoMouthProcessing = 1; _ProcessOptions.DrawAnthropometricPoints = 0; _ProcessOptions.DrawSearchRectangles = 0; _ProcessOptions.DrawFaceRectangle = 1; _ProcessOptions.DrawDetectionTime = 1; _ProcessOptions.DrawFeaturePoints = 1; _ProcessOptions.DoVisualDebug = 0; #region Intialize encapsulated OpenCV subsystem _KLU = new Klu(); _TempBitmap = new System.Drawing.Bitmap(10, 10); // Create a Timer with a Normal Priority _CaptureTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Dispatcher); // Set the callback to just show the time ticking away // NOTE: We are using a control so this has to run on // the UI thread _CaptureTimer.Tick += new EventHandler( delegate(object s, EventArgs a) { _KLU.ProcessCaptureImage(ref _ProcessOptions, ref _FFP); // Ensure the image (bitmap) we are writing to has the correct dimensions int width = 0, height = 0; _KLU.GetLastProcessedImageDims(ref width, ref height); if (_TempBitmap.Width != width || _TempBitmap.Height != height) { Console.WriteLine("Need to resize the _TempBitmap to " + width + "x" + height); _TempBitmap.Dispose(); GC.Collect(); _TempBitmap = new System.Drawing.Bitmap(width, height); } _KLU.GetLastProcessedImage(ref _TempBitmap); _KLU.SetWpfImageFromBitmap(ref image1, ref _TempBitmap); //_KLU.SetImageBrushFromBitmap(ref imageBrush, ref _TempBitmap); } ); #endregion #region "Connect" to database _TAM = new TableAdapterManager(); _DataSet = new TrainingDataSet(); // Load data from SQL database and fill our DataSet _TAM.ExpressionTableAdapter = new ExpressionTableAdapter(); _TAM.TrainingTableAdapter = new TrainingTableAdapter(); LoadData(); #endregion } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public Task <InvokeResult> AddTrainingDataSetAsync([FromBody] TrainingDataSet set) { return(this._mgr.AddTrainingDataSetManager(set, OrgEntityHeader, UserEntityHeader)); }
public Task <InvokeResult> UpdateTrainingDataSetAsync([FromBody] TrainingDataSet set) { this.SetUpdatedProperties(set); return(this._mgr.UpdateTrainingDataSetManager(set, OrgEntityHeader, UserEntityHeader)); }
public abstract double PerformSingleEpochProducingErrorRate(TrainingDataSet trainingDataSet);
public void Start() { var dataSets = new List <TrainingDataSet>(); trainingLogger.Message($"{BELT}{DateTime.Now.TimeOfDay}{BELT}"); trainingLogger.Message("Opening connection to database"); using (var db = new GlobalTerrorismContext()) { var sampleRecord = db.AttackRecords.First(); // assert database connection trainingLogger.Message("Preparing"); var count = db.AttackRecords.Count(); var nulls = 0; initializers = Columns.Select(x => new InputInitializer(x.PropertyInfo)).ToList(); trainingLogger.Message("Downloading data"); var attackRecords = db.AttackRecords.ToList(); trainingLogger.Message("Normalizing data"); for (int i = 0; i < count; i++) { foreach (var initializer in initializers) { initializer.UpdateLimits(attackRecords[i]); } //log.Progress($"Normalizing data: {(float)i / count * 100}%"); } trainingLogger.Message("Creating data sets"); //log.Finish(); for (int i = 0; i < count; i++) { var inputs = initializers.Select(x => x.TryGetValue(attackRecords[i])); if (inputs.Any(x => x == null)) { nulls++; continue; } var dataSet = new TrainingDataSet { Inputs = inputs.Select(x => x.Value).ToArray(), Outputs = CreateOutput(attackRecords[i].Fatalities) }; //log.Progress($"Creating data sets: {(float)i / count * 100}%"); dataSets.Add(dataSet); } //log.Finish(); trainingLogger.Message($"{nulls} records skipped as they contains nulls."); } trainingLogger.Message("Training started"); network.Train( trainingDataSets: dataSets, learningRate: learningRate, learningDataPercentage: learningDataRatio ); trainingLogger.Message("Finished"); trainingLogger.Message($"Training accuracy: {network.Accuracy}"); TrainingCompleted?.Invoke(this, ProcessResult.Success); }
public override double PerformSingleEpochProducingErrorRate(TrainingDataSet trainingDataSet) { neuralNetwork.PredictionFor(trainingDataSet.Inputs, parallelOptions); return(BackPropagate(trainingDataSet.Outputs)); }
public static IEnumerable <TrainingDataSet> BuildTrainingDataForAllInputs( IEnumerable <double[]> inputs, IEnumerable <double[]> outputs) { return(inputs.Zip(outputs, (input, output) => TrainingDataSet.For(input, output))); }