Exemplo n.º 1
0
        public ILayer CreateLayer(int type, int numberOfNeurons, IActivationFunction activationFunction)
        {
            ILayer layer = null;

            switch (type)
            {
            case TYPE_ACTIVATION:
                layer = new ActivationLayer();
                for (int i = 0; i < numberOfNeurons; i++)
                {
                    var neuron = new ActivationNeuron(numberOfNeurons, activationFunction);
                    layer.AddLayer(neuron);
                }
                break;

            case TYPE_DISTANCE:
                layer = new DistanceLayer();
                for (int i = 0; i < numberOfNeurons; i++)
                {
                    var neuron = new DistanceNeuron(numberOfNeurons);
                    layer.AddLayer(neuron);
                }
                break;

            default:
                throw new ArgumentException();
            }


            return(layer);
        }
Exemplo n.º 2
0
        public void CreateDistanceLayerTest()
        {
            LayerFactory        factory             = new LayerFactory();
            IActivationFunction ActivationThresHold = new ThresholdFunction();

            DistanceLayer layer = (DistanceLayer)factory.CreateLayer(NETWORK_TYPE_DISTANCE, INPUT_COUNT, ActivationThresHold);

            Assert.Equal(3, layer.GetNeuronCount());
            DistanceNeuron actNeuron = (DistanceNeuron)layer.GetNeuron(1);

            Assert.NotNull(actNeuron);

            List <ISynapse> inputs = actNeuron.FetchInputs();

            Assert.NotNull(inputs);
            Assert.Equal(INPUT_COUNT, inputs.Count);

            ISynapse input = inputs[1];

            Assert.True(input.Weight != 0);
        }
Exemplo n.º 3
0
        public void AddLayer(object neuron)
        {
            DistanceNeuron DistNeuron = (DistanceNeuron)neuron;

            Neurons.Add(DistNeuron);
        }