Skip to content

Commit

Permalink
Create Program.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 24, 2024
1 parent b844cfb commit 53ae93b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/neuronetwork/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using MathNet.Numerics.LinearAlgebra;

namespace Nexuria.NeuroNetwork
{
class Program
{
static async Task Main(string[] args)
{
var serviceProvider = BuildServiceProvider();
var neuroNetwork = serviceProvider.GetService<NeuroNetwork>();

await neuroNetwork.InitializeAsync();
await neuroNetwork.TrainAsync(Matrix<double>.Build.Dense(10, 10), Matrix<double>.Build.Dense(10, 1));

Console.WriteLine("Press any key to exit...");
Console.ReadKey();

await neuroNetwork.PredictAsync(Matrix<double>.Build.Dense(10, 1));
}

static IServiceProvider BuildServiceProvider()
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();

var serviceProvider = new ServiceCollection()
.AddLogging(logging =>
{
logging.AddConsole();
logging.AddDebug();
})
.AddSingleton<NeuroNetwork>()
.AddSingleton<NeuroNetworkOptions>()
.AddSingleton<IConfiguration>(configuration)
.BuildServiceProvider();

return serviceProvider;
}
}
}

0 comments on commit 53ae93b

Please sign in to comment.