private INeuralModel InitNeuralModel()
        {
            var model = new NeuralModelBase();

            model.defaultWeightInitializer = () => GARandomManager.NextFloat(-1f, 1f);
            model.WeightConstraints        = new Tuple <float, float>(-10, 10);

            var bias   = model.AddBiasNeuron();
            var layers = new List <Neuron[]>()
            {
                model.AddInputNeurons(inputs).ToArray(),

                model.AddNeurons(
                    new Neuron(-1, ActivationFunctions.Gaussian)
                {
                    //ValueModifiers = new[] { Dropout.DropoutFunc(0.06f) },
                },
                    count: inputs
                    ).ToArray(),

                model.AddOutputNeurons(
                    inputs,
                    ActivationFunctions.Sigmoid
                    ).ToArray(),
            };

            model.ConnectLayers(layers);
            model.ConnectBias(bias, layers.Skip(1));

            return(model);
        }
    protected override INeuralModel InitNeuralModel()
    {
        var model = new NeuralModelBase();

        model.defaultWeightInitializer = () => GARandomManager.NextFloat(-1, 1);

        model.WeightConstraints = weightConstraints.ToTuple();

        var layers = new List <Neuron[]>()
        {
            // Inputs
            model.AddInputNeurons(
                agentPrefab.GetComponent <AgentProxy>().nbOfInputs
                ).ToArray(),

            model.AddNeurons(
                new Neuron(-1, ActivationFunctions.TanH),
                count: agentPrefab.GetComponent <AgentProxy>().nbOfInputs * 4
                ).ToArray(),

            // Outputs
            model.AddOutputNeurons(
                agentPrefab.GetComponent <AgentProxy>().nbOfOutputs,
                ActivationFunctions.Sigmoid
                ).ToArray(),
        };

        model.ConnectLayers(layers);

        var outputs = layers.Last();

        //model.ConnectNeurons(outputs, outputs);
        model.ConnectLayers(new[] { outputs, outputs });
        return(model);
    }
        private INeuralModel InitModel()
        {
            var model = new NeuralModelBase();

            model.defaultWeightInitializer = () => GARandomManager.NextFloat(-1, 1);
            model.WeightConstraints        = new Tuple <float, float>(-5, 5);

            var bias   = model.AddBiasNeuron();
            var layers = new[]
            {
                model.AddInputNeurons(1).ToArray(),

                model.AddNeurons(
                    sampleNeuron: new Neuron(-1, ActivationFunctions.Gaussian),
                    count: 1
                    ).ToArray(),

                model.AddOutputNeurons(1, ActivationFunctions.Sigmoid).ToArray()
            };

            model.ConnectBias(bias, layers.Skip(1));
            model.ConnectLayers(layers);

            // Adding RNN
            //foreach (var neuron in layers[1])
            //{
            //	var mem = model.AddNeurons(
            //	    sampleNeuron: new MemoryNeuron(-1, neuron.InnovationNb),
            //		count: 1);
            //	model.AddConnection(mem[0].InnovationNb, neuron.InnovationNb);
            //}

            // Addin LSTM
            var input  = layers.First().First();
            var output = layers[1].First();

            var a = new[] { 1, 2, 3 };

            a.Where(x => x == 0)
            .GroupBy(x => x)
            .ToArray();

            model.AddLSTM(out var lstmIn, out var lstmOut, biasNeuron: bias);
            model.AddConnection(input, lstmIn);
            model.AddConnection(lstmOut, output);
            return(model);
        }
Esempio n. 4
0
        private INeuralModel InitModel()
        {
            var model = new NeuralModelBase();

            model.defaultWeightInitializer = () => GARandomManager.NextFloat(-3, 3);
            model.WeightConstraints        = new Tuple <float, float>(-20, 20);

            var bias   = model.AddBiasNeuron();
            var layers = new[]
            {
                model.AddInputNeurons(2).ToArray(),
                model.AddNeurons(
                    sampleNeuron: new Neuron(-1, ActivationFunctions.Gaussian),
                    count: 1
                    ).ToArray(),
                model.AddOutputNeurons(1, ActivationFunctions.Sigmoid).ToArray()
            };

            model.ConnectBias(bias, layers.Skip(1));
            model.ConnectLayers(layers);

            return(model);
        }