diff --git a/Core/Core/AI/NetworkLogic/AITester.cs b/Core/Core/AI/NetworkLogic/AITester.cs new file mode 100644 index 0000000000000000000000000000000000000000..a5f14fa0a65c9c9c9e19f94dc17f451ae7251789 --- /dev/null +++ b/Core/Core/AI/NetworkLogic/AITester.cs @@ -0,0 +1,51 @@ +using Core.Data; +using NeuralNetwork.NeuralNetNamespace; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Core.AI.NetworkLogic +{ + public class AITester + { + private readonly Model Context; + public AITester(Model model) + { + Context = model; + } + + public void Test() + { + NeuralNet ann = new NeuralNet(); + ann.CreateEmpty(new List<int> { 9, 3, 3, 1 }); + + Feeder input = new Feeder(Context); + input.MaxBatchIteration = 3; + ann.BatchInput(input); + + input = new Feeder(Context); + input.MaxBatchIteration = 1; + + int success = 0; + int fail = 0; + while (input.GetNext()) + { + bool prediction = ann.EvaluateInput(input.Input); + if (prediction == input.Result) + success++; + else + fail++; + } + Console.WriteLine($"success: {success}, fail: {fail} => {(success / (double)(success + fail)) * 100}%"); + /*while (input.GetNext()) + { + Console.WriteLine("Input:"); + input.Input.ForEach(i => Console.Write(i.ToString()+';')); + Console.WriteLine(); + Console.WriteLine("Result:"); + Console.WriteLine(input.Result); + }*/ + } + } +} diff --git a/Core/Core/Core.csproj b/Core/Core/Core.csproj index bfde7d4532839fee36d8a5d8dfa5503eb3016828..ceede946996c70456336c214397a20351732080f 100644 --- a/Core/Core/Core.csproj +++ b/Core/Core/Core.csproj @@ -22,9 +22,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="MathNet.Numerics" Version="4.8.1" /> <PackageReference Include="Microsoft.AspNetCore.App" /> - <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" /> <PackageReference Include="NLog.Config" Version="4.6.2" /> </ItemGroup> diff --git a/Core/Core/Pages/Error.cshtml b/Core/Core/Pages/Error.cshtml deleted file mode 100644 index 09da0d2d0d38e9413a8d565a627ff0dea4484384..0000000000000000000000000000000000000000 --- a/Core/Core/Pages/Error.cshtml +++ /dev/null @@ -1,26 +0,0 @@ -@page -@model ErrorModel -@{ - ViewData["Title"] = "Error"; -} - -<h1 class="text-danger">Error.</h1> -<h2 class="text-danger">An error occurred while processing your request.</h2> - -@if (Model.ShowRequestId) -{ - <p> - <strong>Request ID:</strong> <code>@Model.RequestId</code> - </p> -} - -<h3>Development Mode</h3> -<p> - Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. -</p> -<p> - <strong>The Development environment shouldn't be enabled for deployed applications.</strong> - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> - and restarting the app. -</p> diff --git a/Core/Core/Pages/Error.cshtml.cs b/Core/Core/Pages/Error.cshtml.cs deleted file mode 100644 index 40bee1fd7627b3c787380032d6fe675191aee30d..0000000000000000000000000000000000000000 --- a/Core/Core/Pages/Error.cshtml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Core.Pages -{ - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public class ErrorModel : PageModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} diff --git a/Core/Core/Pages/_ViewImports.cshtml b/Core/Core/Pages/_ViewImports.cshtml deleted file mode 100644 index 996d76facd837b607291ad3bd521d8455847092c..0000000000000000000000000000000000000000 --- a/Core/Core/Pages/_ViewImports.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using Core -@namespace Core.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Core/Core/Program.cs b/Core/Core/Program.cs index 19ce9171f03cba3811bdc45a25a614f6d449662b..26fd25d6227c384ffba45bd3c9c373a2d17fdf5d 100644 --- a/Core/Core/Program.cs +++ b/Core/Core/Program.cs @@ -35,35 +35,8 @@ namespace Core if (trainAI) { - NeuralNet ann = new NeuralNet(); - ann.CreateEmpty(new List<int> { 9, 3, 3, 1 }); - - Feeder input = new Feeder(services.GetRequiredService<Model>()); - input.MaxBatchIteration = 3; - ann.BatchInput(input); - - input = new Feeder(services.GetRequiredService<Model>()); - input.MaxBatchIteration = 1; - - int success = 0; - int fail = 0; - while (input.GetNext()) - { - bool prediction = ann.EvaluateInput(input.Input); - if (prediction == input.Result) - success++; - else - fail++; - } - Console.WriteLine($"success: {success}, fail: {fail} => {(success / (double)(success + fail)) * 100}%"); - /*while (input.GetNext()) - { - Console.WriteLine("Input:"); - input.Input.ForEach(i => Console.Write(i.ToString()+';')); - Console.WriteLine(); - Console.WriteLine("Result:"); - Console.WriteLine(input.Result); - }*/ + AITester tester = new AITester(services.GetRequiredService<Model>()); + tester.Test(); }