This is a section about the Base Foundation of this package, a Neural Network.

Quick Start to use Pure Neural Network

To create a new NeuralNetwork you can use this script

//Create(Execution Mode, Network Structure, Trainer Config)
var NN = GtionNetwork.Create(ExecutionMode.MainThread, new int[]{2,4,1}, TrainerConfig.DefaultConfig);

just that way, you already have the neural network. but the brain is still completely random, so you need to train the Neural Network with your data train.

for example, we will train it with Logic Operation

var result0 = new[] { 0f };
var result1 = new[] { 1f };
var test1 = new[] { 0f, 0f };
var test2 = new[] { 1f, 0f };
var test3 = new[] { 0f, 1f };
var test4 = new[] { 1f, 1f };

//AND Operation Training
for (int i = 0; i < 1000; i++)
{
    NN.Train(test1, result0);
    NN.Train(test2, result0);
    NN.Train(test3, result0);
    NN.Train(test4, result1);
    NN.Evaluate();
}

Note: this neural network, only accepts Input as Float[] and output also in Float[]. the value is in range between 0-1.

This way, you already have your brain trained to do AND operation. you’ll need to save your model, so let's save it to NeuralMemory, you can do it his way

var memory = new NativeNeuralMemory(); //create a bucket to save the memory
NN.SaveMemory(memory); 
memory.SaveTo("MySampleBrain"); 
//save the memory to a file. if you're in editor, the file will be in Assets Folder
//and if you're on build, it'll be under Application.PersistanceDataPath

You’ve done the training process, so now you want to try running this brain, you can do this to load the NN and Execute it

[SerializeField]
NativeNeuralMemory memory;//in inspector

var NN = GtionNetwork.Create(ExecutionMode.MainThread, memory);//load the model
var answer = NN.RunImmidiate(new[] { 1f, 1f });
Debug.Log(answer[0]); //get your answer here

IMPORTANT NOTES: since you’re handling the neural network manually, you need to call Dispose() method to avoid memory leak. ex: NN.Dispose()

Training