public override async Task <int[][]> GenerateConfusionMatrix() { if (TrainingModel.IsTraining) { App.RunInUiThread(() => { NotifyUser.NotifyUserByMessage("Cannot run test. Neural network training is in progress. If you need test neural network please stop training first."); }); return(null); } if (TrainingModel.Network == null) { return(null); } int[][] confusionMatrix = null; try { TrainingModel.InTesting = true; var tester = new NetworkTester(TrainingModel.Network, DataSetModel); var task = Task.Run(() => { tester.RunTest(); return(tester.GenerateConfusionMatrixData()); }); confusionMatrix = await task; task.Dispose(); SuccessRatio = tester.Correctness; } finally { TrainingModel.InTesting = false; } return(confusionMatrix); }
private void ExecuteTestAction() { _canvasContainer.ClearCanvas(CanvasType.Result); NetworkTester networkTester = new NetworkTester(_network); var inputData = PreaperNetworkInput(CanvasType.Test); GameMark gameMark = networkTester.Test(inputData); if (gameMark == GameMark.Circle) { _painterCommand = new DrawCircleCommand(_pen); _canvasContainer.DrawOnCanvas(CanvasType.Result, _painterCommand); GameInfo("Circle"); } if (gameMark == GameMark.Cross) { _painterCommand = new DrawCrossCommand(_pen, _crossDesignator); _canvasContainer.DrawOnCanvas(CanvasType.Result, _painterCommand); GameInfo("Cross"); } else { GameInfo("Blank"); } UpdateCanvasView(CanvasType.Result); }
public override async Task <int[][]> GenerateConfusionMatrix() { try { if (_networkToTest == null) { _networkToTest = TrainedNetModel.GetNetwork(null, DataSetModel); } NetworkTester tester = null; var matrix = await Task.Run(() => { tester = new NetworkTester(_networkToTest, DataSetModel); tester.RunTest(); return(tester.GenerateConfusionMatrixData()); }); SuccessRatio = tester.Correctness; return(matrix); } catch (Exception e) { _networkToTest = null; NotifyUser.NotifyUserByMessage("Network failed to load.", e); return(null); } }
public static Role Build(string roleName, MyIni config, Program program = null) { Role builtRole; switch (roleName) { case "miner": builtRole = new Miner(config); break; case "drone_controller": builtRole = new DroneController(config); break; case "tester": builtRole = new Tester(config); break; case "network_tester": builtRole = new NetworkTester(config); break; case "surveyor": builtRole = new Surveyor(config); break; default: throw new Exception($"Unable to build role: {roleName}"); break; } return(builtRole); }
private static void Main(string[] args) { var net = new Network(); var trainer = new NetworkTrainer(); var tester = new NetworkTester(); trainer.Train(net); tester.Test(net); Console.ReadKey(); }
private void Awake() { levelManager = GameObject.FindGameObjectWithTag("Level").GetComponent <LevelManager>(); hUDManager = GameObject.FindGameObjectWithTag("Hud").GetComponent <HUDManager>(); network = GameObject.FindGameObjectWithTag("Network").GetComponent <NetworkTester>(); if (Instance != null && Instance != this) { Destroy(this.gameObject); } else { Instance = this; } DontDestroyOnLoad(this); }
private bool PrepareBoard() { var humanCanvas = _lastModifiedCanvas; NetworkTester networkTester = new NetworkTester(_network); var canvas = _canvasContainer.GetCanvas(humanCanvas); var humanMark = networkTester.Test(BitmapConverter.ImageToByte(canvas.GetBitmap())); if (humanMark == GameMark.Blank) { GameInfo("Try again"); _canvasContainer.ClearCanvas(humanCanvas); UpdateCanvasView(humanCanvas); return(false); } _game.SetComputerMark(humanMark); _game.UpdateBoard(humanCanvas, humanMark); return(true); }
private async void ChangeWallpaper() { try { //TODO - // Don't need internet access for local folders // while (true) { _cts = new CancellationTokenSource(); var sources = await _db.GetSourcesAsync(); var access = await NetworkTester.HasInternetAccess(); if (access || sources.Any(x => x.Source == Source.Local)) { if (sources.Count > 0) { if (!wasLocal) { foreach (var file in currentImages) { File.Delete(file); } } currentImages.Clear(); OptionEnabled = true; NotifyOfPropertyChange(() => OptionEnabled); WallpaperSource randSource; if (access) { randSource = sources[_rand.Next(sources.Count)]; } else { sources = sources.Where(x => x.Source == Source.Local).ToList(); randSource = sources[_rand.Next(sources.Count)]; } if (randSource.Source == Source.Wallhaven) { randSource.WallhavenOptions = await _db.GetWallhavenOptions(randSource); } Image image = null; var isMultiple = await _db.UseMultiple(); string tempFile = null; wasLocal = (randSource.Source == Source.Local); if (isMultiple) { //testing for multiple monitors var screens = System.Windows.Forms.Screen.AllScreens; //this needs to be modified to allow vertically stacked monitors. //right now only side by side monitors will work using (var bmp = new Bitmap(screens.Sum(x => x.Bounds.Width), screens.Max(x => x.Bounds.Height))) using (var g = Graphics.FromImage(bmp)) { //get a random image for each screen foreach (var s in screens) { string imageUrl = await UrlFetcher.GetRandomImageUrl(randSource, await _db.ImgurClientId(), currentImages); if (String.IsNullOrEmpty(imageUrl)) { if (String.IsNullOrEmpty(tempFile)) { continue; } //do nothing, leave the temp file as the current file } else { if (randSource.Source != Source.Local) { tempFile = await WebImage.DownloadImage(imageUrl); } else { tempFile = imageUrl; } } currentImages.Add(tempFile); image = Image.FromFile(tempFile); //we need to scale the image properly to fit the screen image = WebImage.ScaleImage(image, s.Bounds.Width, s.Bounds.Height); //now figure out the location var x = ((s.Bounds.Width - image.Width) / 2) + s.Bounds.Location.X; var y = ((s.Bounds.Height - image.Height) / 2) + s.Bounds.Location.Y; //draw it onto the screen g.DrawImage(image, new Rectangle(x, y, image.Width, image.Height)); newImages.Add(image); } //now get the file out of it g.Save(); tempFile = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "stitched.bmp"); bmp.Save(tempFile); } } else { string imageUrl = await UrlFetcher.GetRandomImageUrl(randSource, await _db.ImgurClientId(), currentImages); if (!String.IsNullOrEmpty(imageUrl)) { if (randSource.Source != Source.Local) { tempFile = await WebImage.DownloadImage(imageUrl); } else { tempFile = imageUrl; } image = Image.FromFile(tempFile); newImages.Add(image); currentImages.Add(tempFile); } } if (!currentImages.All(x => String.IsNullOrEmpty(x))) { DesktopBackground.SetWallpaper(tempFile, isMultiple); ToolTipInfo = string.Format("Source: {0}\r\nResolution: {1}", randSource.Source == Source.Reddit ? randSource.Query : randSource.Source + " / " + randSource.Query, newImages.Aggregate("", (c, v) => $"{c}\r\n{v.Width}x{v.Height}")); NotifyOfPropertyChange(() => ToolTipInfo); } foreach (var i in newImages) { i.Dispose(); } newImages.Clear(); } else { ToolTipInfo = "Please add sources!"; NotifyOfPropertyChange(() => ToolTipInfo); OptionEnabled = false; NotifyOfPropertyChange(() => OptionEnabled); } await Task.Delay(TimeSpan.FromMinutes(await _db.Interval()), _cts.Token).ContinueWith(tsk => { }); } else { ToolTipInfo = "Waiting for internet access..."; NotifyOfPropertyChange(() => ToolTipInfo); OptionEnabled = false; NotifyOfPropertyChange(() => OptionEnabled); await Task.Delay(TimeSpan.FromSeconds(30)); } } } catch (Exception e) { e = e; } }