U
U
Uncle Bogdan2021-08-22 15:27:58
Neural networks
Uncle Bogdan, 2021-08-22 15:27:58

Explain for this neural network?

I want a neural network for a turn-based strategy.

Found this thing: https://github.com/kipgparker/MutationNetwork/blob...

Entered this:

private void UseNeuralNetwork()
    {
        CalculateAttackVariant();
        CalculateMoveVariant();

        float[] inputs = new float[5];

        inputs[0] = MoveVariants.Count;
        inputs[1] = AttackVariants.Count;
        inputs[2] = Health;
        inputs[3] = Damage;
        inputs[4] = GridActions.PlayerTurn.CalculateMinimalDistance(GridActions.PlayerTurn.PlayerUnits, transform.position);
        _brain.fitness = fitness;

        var output = _brain.FeedForward(inputs);

        print(output[0]);
        
    }


Output 0.56 to the console. What is the logic? Does it output a number from 0 to 1?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
berng, 2021-08-22
@berng

from -1 to 1. Outputs the activation function after the neurons of the last layer of the network, and there tanh.
In fact, this is the result of the network, if the network is trained. To load the trained coefficients, you need to run _brain.Load().
Judging by the code, it learns step by step, by a genetic algorithm through the Mutate function, it looks for the optimum through the CompareTo function in comparison with other objects in order to optimize its fitness in relation to others.
fitness should somehow be calculated based on your needs after each mutation step.
There is no genetic learning algorithm itself here, there are only auxiliary functions that greatly facilitate its implementation. You need to write the learning process yourself or look for how it is implemented in other code files, or load the trained network coefficients from a file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question