/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { _captureManager = await new MediaCaptureWrapperFactory().Create(); capturePreview.Source = _captureManager.MediaCapture; // _captureManager.StartPreview(); var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); await Task.Run(() => { _classifier = NeuralNetFactory.CreateNetWithPredefinedWeights(picturesLibrary.SaveFolder.Path + @"\weights.txt", 13, 6); }); }
public void TestHogOnAllNewDataWithPerformanceAndConfidence(string dataPath) { var folds = 5; for (int i = 0; i < folds; i++) { var allData = Reading.ReadAllFiles(dataPath, folds); var testData = allData[i]; allData.RemoveAt(i); var data = Reading.MergeReadings(allData); Link.RenewalFactor = 0.000003; // maybe decrease Link.Step = 0.05; var sut = NeuralNetFactory.Create(2, 10, data.InputValues[0].Count, data.ExpectedResults[0].Count); var iterations = sut.TrainAdaptiveWithConfidenceAndPerformance(data.InputValues, data.ExpectedResults, -0.00005, 150000, testData, i, dataPath); } }
public static void Test(string[] args) { // Read training set string trainFile = args[0]; DataFrame df = DataFrame.Read(trainFile, sep: '\t'); foreach (string s in df.Headers()) { Console.WriteLine(s); } double[] x = df["x"].ToDouble(); double[] y = df["y"].ToDouble(); // Prepare training set int nTrain = x.Length; double[][] xTrain = new double[nTrain][]; double[][] yTrain = new double[nTrain][]; for (int i = 0; i < nTrain; i++) { xTrain[i] = new double[] { x[i] }; yTrain[i] = new double[] { y[i] }; } // Set up model string activation = "Relu"; int nHiddenLayers = 0; int nNeuronsPerLayer = 2; int inputSize = xTrain[0].Length; int outputSize = yTrain[0].Length; double alpha = 0.5; double eta = 0.15; NeuralNet model = NeuralNetFactory.Get(activation, nHiddenLayers, nNeuronsPerLayer, inputSize, outputSize, alpha, eta); model.Fit(xTrain, yTrain); // Predict string predFile = args[1]; df = DataFrame.Read(predFile, sep: '\t'); foreach (string s in df.Headers()) { Console.WriteLine(s); } //double[] xPred_ = df["x"].ToDouble(); //double[][] xPred = new double[xPred_.Length][]; //for (int i = 0; i < xPred_.Length; i++) // xPred[i] = new double[1] { xPred_[i] }; double[][] xPred = df.SetAsDouble(new string[] { "x" }); double[] yPred = model.Predict(xPred); // Output result string resFile = args[2]; object[][] resData = yPred.Select(z => new object[] { z }).ToArray(); CsvManager.Write(resData, resFile, sep: '\t'); //model.BackPropagation(); string ss = ""; ss += ""; //string type = "Standard"; //Scaler scaler = Scaler.Create(type); //scaler.Fit(); }