Пример #1
0
        public HiddenLayer CreateHiddenLayer()
        {
            HiddenLayer hiddenLayer;

            hiddenLayer = new HiddenLayer();
            HiddenLayers.Add(hiddenLayer);

            return(hiddenLayer);
        }
 public NeuralNetwork(int inputNeurons, int hiddenNeurons, int outputNeurons, int hidLayers)
 {
     InputLayer = new InputLayer(inputNeurons);
     for (int i = 0; i < hidLayers; i++)
     {
         HiddenLayers.Add(new HiddenLayer(hiddenNeurons));
     }
     OutputLayer = new OutputLayer(outputNeurons);
     Generate();
     CreateSubscribes();
 }
Пример #3
0
    public void InitializeHiddenLayers(int[] hiddenNeuronCount)
    {
        InputLayer.Clear();
        HiddenLayers.Clear();
        OutputLayer.Clear();

        foreach (var neuronsCount in hiddenNeuronCount)
        {
            var newHiddenLayer = new Matrix(1, neuronsCount);
            HiddenLayers.Add(newHiddenLayer);
        }
    }
Пример #4
0
        void AddSynapse(Synapse template)
        {
            if (AllSynapses.ContainsKey(template.InnovationNo))
            {
                Debug.Log("wtf??");
                Debug.Break();
            }
            Neuron neuron1 = null, neuron2 = null;

            if (template.InputNeuron.InnovationNo <= InputLayer.Count)
            {
                neuron1 = InputLayer[template.InputNeuron.InnovationNo - 1];
            }
            else
            {
                if (HiddenLayers.ContainsKey(template.InputNeuron.InnovationNo))
                {
                    neuron1 = HiddenLayers[template.InputNeuron.InnovationNo];
                }
                else
                {
                    neuron1 = new Neuron(template.InputNeuron);
                    HiddenLayers.Add(neuron1.InnovationNo, neuron1);
                }
            }
            if (template.OutputNeuron.InnovationNo <= InputLayer.Count + OutputLayer.Count)
            {
                neuron2 = OutputLayer[template.OutputNeuron.InnovationNo - InputLayer.Count - 1];
            }
            else
            {
                if (HiddenLayers.ContainsKey(template.OutputNeuron.InnovationNo))
                {
                    neuron2 = HiddenLayers[template.OutputNeuron.InnovationNo];
                }
                else
                {
                    neuron2 = new Neuron(template.OutputNeuron);
                    HiddenLayers.Add(neuron2.InnovationNo, neuron2);
                }
            }

            Synapse newSyn = new Synapse(neuron1, neuron2, template.InnovationNo);

            newSyn.Weight = template.Weight;
            AllSynapses.Add(newSyn.InnovationNo, newSyn);
            //Debug.Log("Koniec add synapse template");
        }
Пример #5
0
    public NeuralGeneNode AddHiddenNode(NeuralActivationFunction _neuralActivationFunctions)
    {
        if (HiddenLayers == null)
        {
            HiddenLayers = new List <NeuralGeneNode>();
        }
        if (nodes == null)
        {
            nodes = new List <NeuralGeneNode>();
        }
        NeuralGeneNode tmpNode = new NeuralGeneNode(_neuralActivationFunctions, nodes.Count + 1, NeuralNodeType.Hidden);

        HiddenLayers.Add(tmpNode);
        nodes.Add(tmpNode);
        return(tmpNode);
    }
Пример #6
0
        public SantoriniNN()
        {
            OutputLayer = new Layer(_OutputNeurons);
            Layer lastLayer = null;

            for (int i = 0; i < _NumberOfHiddenLayers; i++)
            {
                if (lastLayer == null)
                {
                    lastLayer = new Layer(_NumberOfHiddenNeurons, OutputLayer);
                    HiddenLayers.Add(lastLayer);
                }
                else
                {
                    Layer l = new Layer(_NumberOfHiddenNeurons, lastLayer);
                    lastLayer = l;
                    HiddenLayers.Add(lastLayer);
                }
            }
            InputLayer = new Layer(175, lastLayer);
        }
Пример #7
0
    private void InitHiddenLayers(int inputsAmount, int[] neuronsInHiddenLayersAmount)
    {
        for (var neuronsCount = 0; neuronsCount < neuronsInHiddenLayersAmount.Length; neuronsCount++)
        {
            var hiddenLayer = new Matrix(1, neuronsInHiddenLayersAmount[neuronsCount]);
            HiddenLayers.Add(hiddenLayer);
            Biases.Add(Random.Range(-1f, 1f));

            if (neuronsCount == 0)
            {
                var weightsInputToHiddenLayer1 = new Matrix(inputsAmount, neuronsInHiddenLayersAmount[neuronsCount]);
                Weights.Add(weightsInputToHiddenLayer1);
            }
            else
            {
                var weightsHliToNextHl = new Matrix(neuronsInHiddenLayersAmount[neuronsCount - 1],
                                                    neuronsInHiddenLayersAmount[neuronsCount]);
                Weights.Add(weightsHliToNextHl);
            }
        }
    }
Пример #8
0
        public Network(int inputSize, int[] hiddenSizes, int outputSize, double learnRate = 0.4, double momentum = 0.9)
        {
            this.LearnRate    = learnRate;
            this.Momentum     = momentum;
            this.InputLayer   = new List <Neuron>();
            this.HiddenLayers = new List <List <Neuron> >();
            this.OutputLayer  = new List <Neuron>();

            for (var i = 0; i < inputSize; i++)
            {
                InputLayer.Add(new Neuron());
            }

            var firstHiddenLayer = new List <Neuron>();

            for (var i = 0; i < hiddenSizes[0]; i++)
            {
                firstHiddenLayer.Add(new Neuron(InputLayer));
            }

            HiddenLayers.Add(firstHiddenLayer);

            for (var i = 1; i < hiddenSizes.Length; i++)
            {
                var hiddenLayer = new List <Neuron>();
                for (var j = 0; j < hiddenSizes[i]; j++)
                {
                    hiddenLayer.Add(new Neuron(HiddenLayers[i - 1]));
                }
                HiddenLayers.Add(hiddenLayer);
            }

            for (var i = 0; i < outputSize; i++)
            {
                OutputLayer.Add(new Neuron(HiddenLayers.Last()));
            }
        }