Example #1
0
 public Neuron(int inputCount, NeuronType type = NeuronType.Normal)
 {
     NeuronType = type;
     Weights    = new List <double>();
     Inputs     = new List <double>();
     InitWeightsRandomValue(inputCount);
 }
Example #2
0
 public OneNeuron(int inpCount, NeuronType nt = NeuronType.Normal)
 {
     NType   = nt;
     Inputs  = new List <double>();
     Weights = new List <double>();
     InitWeights(inpCount);
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Neuron"/> class.
 /// </summary>
 /// <param name="id">Id of the neuron.</param>
 /// <param name="name">Name of the neuron.</param>
 /// <param name="type">Type of the neuron.</param>
 /// <param name="bias">Bias of the neuron.</param>
 public Neuron(int id, string name, NeuronType type, double bias = 0)
 {
     this.Id   = id;
     this.Name = name;
     this.Type = type;
     this.Bias = bias;
 }
Example #4
0
        /*
         *
         * METHODS
         *
         */

        // Constructor with configuration
        public Dendrite(Random random, NeuronType neuronType, bool isSynapseInNeuronInInputLayer = false)
        {
            IsInInputLayer = isSynapseInNeuronInInputLayer;
            Weight         = IsInInputLayer ? 1 : getInitialDendriteWeight(random, neuronType);
            SignalInput    = 0;
            SignalOutput   = 0;
        }
Example #5
0
        public Layer(List <Neuron> neurons, NeuronType type = NeuronType.Normal)
        {
            //TODO: проверить входные нейроны на соответствие

            Neurons = neurons;
            Type    = type;
        }
Example #6
0
        public Neuron(int id, CnnNet cnnNet, 
			IEnumerable<AxonGuidanceForceBase> axonGuidanceForces, 
			IEnumerable<SomaGuidanceForceBase> somaGuidanceForces,
			NeuronType type)
        {
            Contract.Requires<ArgumentException>(id >= 0);
            Contract.Requires<ArgumentNullException>(cnnNet != null);
            Contract.Requires<ArgumentNullException>(axonGuidanceForces != null);
            Contract.Requires<ArgumentNullException>(somaGuidanceForces != null);

            Id = id;
            Network = cnnNet;
            AxonWayPoints = new List<NeuronAxonWaypoint>
            {
                new NeuronAxonWaypoint(1, this, new Point(PosX, PosY))
            };
            AxonGuidanceForces = new ReadOnlyCollection<AxonGuidanceForceBase>(axonGuidanceForces.ToList());
            SomaGuidanceForces = new ReadOnlyCollection<SomaGuidanceForceBase>(somaGuidanceForces.ToList());

            Type = type;
            HasSomaReachedFinalPosition = Type == NeuronType.Input || Type == NeuronType.Output;
            HasAxonReachedFinalPosition = Type == NeuronType.Output;

            _synapses = new List<DendricSynapse>();
            _synapsesActivationHistory = new FixedSizedQueue<DendricSynapse[]>(cnnNet.NeuronActivityHistoryLength);
            _random = new Random();
        }
Example #7
0
        public Neuron(int id, CnnNet cnnNet,
                      IEnumerable <AxonGuidanceForceBase> axonGuidanceForces,
                      IEnumerable <SomaGuidanceForceBase> somaGuidanceForces,
                      NeuronType type)
        {
            Contract.Requires <ArgumentException>(id >= 0);
            Contract.Requires <ArgumentNullException>(cnnNet != null);
            Contract.Requires <ArgumentNullException>(axonGuidanceForces != null);
            Contract.Requires <ArgumentNullException>(somaGuidanceForces != null);

            Id            = id;
            Network       = cnnNet;
            AxonWayPoints = new List <NeuronAxonWaypoint>
            {
                new NeuronAxonWaypoint(1, this, new Point(PosX, PosY))
            };
            AxonGuidanceForces = new ReadOnlyCollection <AxonGuidanceForceBase>(axonGuidanceForces.ToList());
            SomaGuidanceForces = new ReadOnlyCollection <SomaGuidanceForceBase>(somaGuidanceForces.ToList());

            Type = type;
            HasSomaReachedFinalPosition = Type == NeuronType.Input || Type == NeuronType.Output;
            HasAxonReachedFinalPosition = Type == NeuronType.Output;

            _synapses = new List <DendricSynapse>();
            _synapsesActivationHistory = new FixedSizedQueue <DendricSynapse[]>(cnnNet.NeuronActivityHistoryLength);
            _random = new Random();
        }
Example #8
0
        /// <summary>
        /// Создание слоя нейронов
        /// </summary>
        /// <param name="neurons"></param> коллекция нейронов
        /// <param name="type"></param> тип нейронов в этом слое
        public Layer(List <Neuron> neurons, NeuronType type = NeuronType.Normal)
        {
            //Проверка на соответствие типу создаваемого слоя
            bool ok = false;

            for (int i = 0; i < neurons.Count; i++)
            {
                if (neurons[i].NeuronType != type)
                {
                    MessageBox.Show($"Layer contains zero neurons.\n" +
                                    $"Incorrect collection '{neurons}' neuron by index {i} type in constructor parameters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ok = false;
                    break;
                }
                else
                {
                    ok = true;
                }
            }

            if (ok)
            {
                Neurons = neurons;
                Type    = type;
            }
            else
            {
                Neurons = null;
            }
        }
Example #9
0
        }                                        //Дельта

        /// <summary>
        /// Создание нейрона
        /// </summary>
        /// <param name="inputCount"></param> количество входных сигналов
        /// <param name="type"></param> тип нейрна
        public Neuron(int inputCount, NeuronType type = NeuronType.Normal)
        {
            //проверка входных параметров
            try
            {
                NeuronType = type;
            }
            catch (InvalidCastException e)
            {
                MessageBox.Show(e.Message, "Error input", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            try
            {
                if (inputCount >= 1)
                {
                    //Добаление весов
                    Weights = new List <double>();
                    Inputs  = new List <double>();

                    InitWeghtsRandomValue(inputCount);
                }
                else
                {
                    MessageBox.Show("The number of inputs can't be less than 1", "Error input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (InvalidCastException e)
            {
                MessageBox.Show(e.Message, "Error input", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #10
0
        public Layer(List <Neuron> neurons, NeuronType type = NeuronType.Normal)
        {
            // RODO: Проверка на соответствие типу

            Neurons   = neurons;
            this.Type = type;
        }
Example #11
0
 // Конструктор
 // Принимает как аргументы входное значение нейрона и тип нейрона
 public Neuron(double input, NeuronType type)
 {
     this.input   = input;
     this.type    = type;
     this.output  = Sigmoid(input);
     this.weights = new List <double>();
 }
Example #12
0
        public InputGUI(int rows, int cols, bool dontCount = false)
            : base()
        {
            // Используемый тип нейрона
            neuronType = NeuronType.Binary;
            //

            if(!dontCount)
            ++objectCounter;
            titleLabel = new Button();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            //
            // dataGridView
            //
            this.AllowUserToAddRows = false;
            this.AllowUserToDeleteRows = false;
            this.AllowUserToResizeColumns = false;
            this.AllowUserToResizeRows = false;
            this.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable;
            this.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
            //this.ColumnHeadersHeight = 5;
            this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.ColumnHeadersVisible = false;
            this.Location = new System.Drawing.Point(0, 0);
            this.MultiSelect = false;
            this.Name = "dataGridView" + objectCounter;
            this.ReadOnly = true;
            this.RowHeadersVisible = false;
            //this.RowHeadersWidth = 5;
            this.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
            //dataGridViewCellStyle5.BackColor = Color.FromArgb(0); //System.Drawing.Color.White;
            //dataGridViewCellStyle5.ForeColor = Color.FromArgb(0); //System.Drawing.Color.White;
            dataGridViewCellStyle5.SelectionBackColor = Color.FromArgb(0); //System.Drawing.Color.Red;
            dataGridViewCellStyle5.SelectionForeColor = Color.FromArgb(0);// System.Drawing.Color.White;
            this.RowsDefaultCellStyle = dataGridViewCellStyle5;
            this.RowTemplate.Height = cellHeight;
            this.RowTemplate.ReadOnly = true;
            this.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
            this.ScrollBars = System.Windows.Forms.ScrollBars.None;
            this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
            this.Size = new System.Drawing.Size(cols * cellWidth + (cols - 1), rows * cellHeight + (rows - 2));
            this.TabIndex = objectCounter;

            this.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseClick);
            this.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseDown);
            this.CellMouseMove += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseMove);
            this.CellMouseUp += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseUp);
            this.MouseLeave += new System.EventHandler(this.dataGridView1_MouseLeave);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            ///////////////////
            ///////////////////
            ///////////////////
            this.RowCount = rows;
            this.ColumnCount = cols;

            drawMode = false;
            selectionCellColor = Color.FromArgb(255, 255, 128, 255);
        }
        // Инициализирует список нейронов с входными значениями 0
        // Если слой не выходной, то генерирует ещё и нейрон смещения (в конце списка) со значением 1
        public void InitNeurons()
        {
            this.neurons = new List <Neuron>();
            for (int i = 0; i < this.length; i++)
            {
                NeuronType type = NeuronType.Hidden;
                switch (this.type)
                {
                case LayerType.Input:
                    type = NeuronType.Input;
                    break;

                case LayerType.Output:
                    type = NeuronType.Output;
                    break;

                case LayerType.Hidden:
                    type = NeuronType.Hidden;
                    break;
                }
                Neuron neuron = new Neuron(0, type);
                this.neurons.Add(neuron);
            }

            // Если слой не является выходным, добавляем туда ещё нейрон смещения
            if (this.type != LayerType.Output)
            {
                this.neurons.Add(new Neuron(1, NeuronType.Bias));
            }
        }
Example #14
0
 public Neuron(int weights, double value, NeuronType type)
 {
     Value   = value;
     Weights = new double[weights];
     Type    = type;
     GenerateWeights(weights);
 }
Example #15
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="copyFrom"></param>
 public NeuronGene(NeuronGene copyFrom)
 {
     this.innovationId = copyFrom.innovationId;
     this.neuronType = copyFrom.neuronType;
     this.activationFunction = copyFrom.activationFunction;
     this.Layer = copyFrom.Layer;
 }
Example #16
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="copyFrom"></param>
 public NeuronGene(NeuronGene copyFrom)
 {
     this.innovationId       = copyFrom.innovationId;
     this.neuronType         = copyFrom.neuronType;
     this.activationFunction = copyFrom.activationFunction;
     this.Layer = copyFrom.Layer;
 }
Example #17
0
 public static PropertyObject NodeWithProperties(long uniqueID, NeuronType nt)
 {
     return(new PropertyObject()
     {
         { WINNode.SUniqueString, uniqueID.ToString() }, { WINNode.SNodeString, nt.ToString() }
     });
 }
Example #18
0
 public Neuron(NeuronType type, double result) : this(type)
 {
     if (type == NeuronType.Input)
     {
         _result = result;
     }
 }
Example #19
0
        public override WizardPanel GetNext()
        {
            NeuronType ntype =
                uiUnipolar.Checked ? NeuronType.Unipolar : NeuronType.Bipolar;

            return(new ExperimentPanel((int)uiInputCount.Value, ntype));
        }
Example #20
0
        public NeuronType[][] CreateMaket(int[] network)
        {
            NeuronType[][] maket = new NeuronType[network.Length][];

            for (int i = 0; i < network.Length; i++)
            {
                if (i != network.Length - 1)
                {
                    maket[i] = new NeuronType[network[i] + 1];
                }
                else
                {
                    maket[i] = new NeuronType[network[i]];
                }
            }

            for (int i = 0; i < maket.Length; i++)
            {
                if (i == 0)
                {
                    for (int j = 0; j < maket[i].Length; j++)
                    {
                        if (j == maket[i].Length - 1)
                        {
                            maket[i][j] = NeuronType.Bias;
                        }
                        else
                        {
                            maket[i][j] = NeuronType.Input;
                        }
                    }
                    continue;
                }

                if (i == maket.Length - 1)
                {
                    for (int j = 0; j < maket[i].Length; j++)
                    {
                        maket[i][j] = NeuronType.Output;
                    }
                    continue;
                }

                for (int j = 0; j < maket[i].Length; j++)
                {
                    if (j == maket[i].Length - 1)
                    {
                        maket[i][j] = NeuronType.Bias;
                        continue;
                    }
                    else
                    {
                        maket[i][j] = NeuronType.Hidden;
                    }
                }
            }

            return(maket);
        }
Example #21
0
 public NeuronGene(uint innovationId, NeuronType neuronType, IActivationFunction activationFunction)
 {
     this.innovationId       = innovationId;
     this.neuronType         = neuronType;
     this.activationFunction = activationFunction;
     this.neuronBias         = 0;
     this.timeConstant       = 1;
 }
Example #22
0
 public Layer(IEnumerable <Neuron> neurons, NeuronType type = NeuronType.Normal)
 {
     if (AreAllNeuronsHaveSameType(neurons, type))
     {
         throw new TypeAccessException("all neurons should have same type");
     }
     Neurons = new List <Neuron>(neurons);
 }
Example #23
0
        /// <summary>
        /// [int] - Количество входящих нейронов, [NeuronType] - тип создаваемого нейрона
        /// </summary>
        public Neuron(int inputCountNeuron, NeuronType type = NeuronType.Hidden)
        {
            Weights      = new List <float>();
            InputSignals = new List <float>();
            NeuronType   = type;

            InitWeightsRandomValues(inputCountNeuron);
        }
Example #24
0
 public NeuronGene(uint innovationId, NeuronType neuronType, IActivationFunction activationFunction, float layer = -1)
 {
     this.innovationId       = innovationId;
     this.neuronType         = neuronType;
     this.activationFunction = activationFunction;
     this.TimeConstant       = 1;
     this.Layer = layer;
 }
 public NeuronGene(NeuronType type, int id, double y, double x, bool r = false)
 {
     this.ID         = id;
     this.SplitY     = y;
     this.SplitX     = x;
     this.Recurrent  = r;
     this.NeuronType = type;
 }
 /// <summary>
 /// 实例化
 /// </summary>
 /// <param name="nodeCount">当前层节点数量</param>
 public NeuronLayer(int nodeCount, NeuronType layerType = NeuronType.Sigmoid)
 {
     this.LayerType = layerType;
     for (var i = 0; i < nodeCount; i++)
     {
         NodeList.Add(new NeuronNode(layerType));
     }
 }
        private static Neuron ReadNeuron(XmlElement xmlNeuron)
        {
            uint       id           = uint.Parse(XmlUtilities.GetAttributeValue(xmlNeuron, "id"));
            NeuronType neuronType   = XmlUtilities.GetNeuronType(XmlUtilities.GetAttributeValue(xmlNeuron, "type"));
            string     activationFn = XmlUtilities.GetAttributeValue(xmlNeuron, "activationFunction");

            return(new Neuron(ActivationFunctionFactory.GetActivationFunction(activationFn), neuronType, id));
        }
Example #28
0
 public NeuronGene(uint innovationId, NeuronType neuronType, IActivationFunction activationFunction, float layer)
 {
     this.innovationId = innovationId;
     this.neuronType = neuronType;
     this.activationFunction = activationFunction;
     this.TimeConstant = 1;
     this.Layer = layer;
     //Console.WriteLine("LAYER LAYER LAYER!");
 }
        public Neuron(int inputCount, NeuronType type = NeuronType.Normal)
        {
            NeuronType = type;
            Weights    = new double[inputCount];
            Inputs     = new double[inputCount];
            Deltas     = new double[inputCount];

            InitWeightsRandomValues(inputCount);
        }
Example #30
0
 public Neuron(List <double> inputs, List <double> weights, NeuronType neuronType, int mapX, int mapY)
 {
     Inputs      = inputs;
     Weight      = weights;
     _NeuronType = neuronType;
     MapX        = mapX;
     MapY        = mapY;
     LastNeurons = new List <Neuron>();
 }
Example #31
0
        private static NeuronGene ReadNeuronGene(XmlElement xmlNeuronGene)
        {
            uint       id           = uint.Parse(XmlUtilities.GetAttributeValue(xmlNeuronGene, "id"));
            float      layer        = (float)Convert.ToDouble(XmlUtilities.GetAttributeValue(xmlNeuronGene, "layer"));
            NeuronType neuronType   = XmlUtilities.GetNeuronType(XmlUtilities.GetAttributeValue(xmlNeuronGene, "type"));
            string     activationFn = XmlUtilities.GetAttributeValue(xmlNeuronGene, "activationFunction");

            return(new NeuronGene(id, neuronType, ActivationFunctionFactory.GetActivationFunction(activationFn), layer));
        }
        private static NeuronGene ReadNeuronGene(XmlElement xmlNeuronGene)
        {
            uint       id           = uint.Parse(XmlUtilities.GetAttributeValue(xmlNeuronGene, "id"));
            NeuronType neuronType   = XmlUtilities.GetNeuronType(XmlUtilities.GetAttributeValue(xmlNeuronGene, "type"));
            string     activationFn = XmlUtilities.GetAttributeValue(xmlNeuronGene, "activationFunction");
            double     layer        = double.Parse(XmlUtilities.GetAttributeValue(xmlNeuronGene, "layer"));

            return(new NeuronGene(null, id, layer, neuronType, ActivationFunctionFactory.GetActivationFunction(activationFn)));
        }
Example #33
0
 public OneNeuron(int inpCount, NeuronType nt = NeuronType.Normal)
 {
     NType   = nt;
     Weights = new List <double>();
     for (var i = 0; i < inpCount; i++)
     {
         Weights.Add(1);
     }
 }
Example #34
0
        public Neuron(int inputCount, NeuronType type = NeuronType.Normal)
        {
            //TODO: check input data in Neuron class.
            NeuronType = type;
            Weights    = new List <double>();
            Inputs     = new List <double>();

            InitRandomWeights(inputCount);
        }
Example #35
0
		public NeuronGene(uint innovationId, NeuronType neuronType, IActivationFunction activationFunction)
		{
			this.innovationId = innovationId;
			this.neuronType = neuronType;
            this.activationFunction = activationFunction;
            this.TimeConstant = 1;
            this.Layer = 10; // default value to signify that Layers are not being used. Normally Layer is between 0 and 1
            //Console.WriteLine("wut, no layer?");
		}
 public NeuronGene(NeuronGene other)
 {
     this.type = other.type;
       this.innovationId = other.innovationId;
       this.a = other.a;
       this.b = other.b;
       this.c = other.c;
       this.d = other.d;
       this.mean = other.mean;
       this.sigma = other.sigma;
 }
 public NeuronGene(int innovationId, NeuronType type, float a, float b, float c, float d, float mean, float sigma)
 {
     this.innovationId = innovationId;
       this.type = type;
       this.a = a;
       this.b = b;
       this.c = c;
       this.d = d;
       this.mean = mean;
       this.sigma = sigma;
 }
 public NeuronGene(int innovationId, NeuronType type)
 {
     this.type = type;
       this.innovationId = innovationId;
       this.a = 0.5f;
       this.b = 0.5f;
       this.c = 0.5f;
       this.d = 0.5f;
       this.mean = 0.5f;
       this.sigma = 1.0f;
 }
Example #39
0
		public Neuron(IActivationFunction activationFn, NeuronType neuronType, uint id)
		{
			this.activationFn = activationFn;
			this.neuronType = neuronType;
			this.id = id;
			connectionList = new ConnectionList();

			if(neuronType == NeuronType.Bias)
				this.outputValue = 1.0D;
			else
				this.outputValue = 0.0D;
		}
Example #40
0
File: MP.cs Project: babaq/Soul
 public MP(string name, Point3D position, IHillock hillock, double initpotential, double startT)
 {
     id = Guid.NewGuid();
     this.name = name;
     this.position = position;
     synapses = new Dictionary<Guid, ISynapse>();
     currentsources = new Dictionary<Guid, ICurrentSource>();
     this.hillock = hillock;
     this.hillock.HostNeuron = this;
     this.initpotential = initpotential;
     ReSet(startT);
     parentnetwork = null;
     dynamicrule = null;
     type = NeuronType.MP;
 }
		public static string GetNeuronTypeString(NeuronType type)
		{
			switch(type)
			{
				case NeuronType.Bias:
					return "bias";
				case NeuronType.Hidden:
					return "hid";
				case NeuronType.Input:
					return "in";
				case NeuronType.Output:
					return "out";
				default:
					return string.Empty;
			}
		}
Example #42
0
 public NeuronGene(NeuronGene copyFrom, uint _innovationId, double _layer, NeuronType _neuronType, IActivationFunction _activationFunction)
 {
     if (copyFrom != null)
     {
         this.innovationId = copyFrom.InnovationId;
         this.neuronType = copyFrom.NeuronType;
         this.activationFunction = copyFrom.ActivationFunction;
         this.Layer = copyFrom.Layer;
     }
     else
     {
         this.innovationId = _innovationId;
         this.neuronType = _neuronType;
         this.activationFunction = _activationFunction;
         this.Layer = _layer;
     }
 }
Example #43
0
        public ICell Develop(NeuronType neurontype, double threshold = -50, double initpotential = -60, double restpotential = -60, double r = 5, double c = 2, double resetpotential = -60, double refractoryperiod = 1)
        {
            INeuron neuron = null;
            switch (neurontype)
            {
                case NeuronType.MP:
                    neuron = new MP(threshold, initpotential);
                    break;
                case NeuronType.LI:
                    neuron = new LI(threshold, initpotential, r, c, restpotential);
                    break;
                case NeuronType.IF:
                    neuron = new IF(threshold, resetpotential, refractoryperiod, initpotential, r, c, restpotential);
                    break;
            }

            return Develop(neuron);
        }
Example #44
0
 public static Color Dyes(NeuronType type)
 {
     Color color;
     switch (type)
     {
         case NeuronType.HH:
             color = Colors.Blue;
             break;
         case NeuronType.IF:
             color = Colors.Red;
             break;
         case NeuronType.LI:
             color = Colors.Green;
             break;
         default:
             color = Colors.White;
             break;
     }
     return color;
 }
Example #45
0
		public ModelNeuron(NeuronType neuronType, uint id, IActivationFunction funct)
		{
			this.neuronType = neuronType;
			this.id = id;
            this.function = funct;
		}
 public Neuron(NeuronType type)
 {
     Type = type;
 }
Example #47
0
 public NeuronGene(uint innovationId, NeuronType neuronType, IActivationFunction activationFunction)
 {
     this.innovationId = innovationId;
     this.neuronType = neuronType;
     this.activationFunction = activationFunction;
 }
Example #48
0
 // Функция активации
 int ActivateFunc(double sum, double threshold, NeuronType neuronType)
 {
     return (sum >= threshold ? NeuroActive(neuronType) : NeuroPassive(neuronType));
 }
Example #49
0
 static int NeuroPassive(NeuronType nt)
 {
     switch (nt)
     {
         case NeuronType.Binary:
             return 0;
         case NeuronType.Bipolar:
             return -1;
         default:
             return 0;
     }
 }