neuron.cs

来自「AI Life (Neural Networks, Genetic Algori」· CS 代码 · 共 43 行

CS
43
字号
using System;

namespace AI_Life
{

	public class Neuron
	{

        //=========================================================//
		int numInputs;		// number of inputs
		double[] weights;	// array of weights

		public Neuron(int initNumInputs)
		{
			numInputs = initNumInputs + 1; // + 1 for bias
			weights = new double[numInputs];

			for (int i=0; i<numInputs; i++)
				weights[i] = ((float)(Cosmos.randomR.NextDouble()) * 2) - 1;

		}

		public double NumInputs
		{
            get
            {
                return numInputs;
            }
		}

		public void SetWeight(int index, double newVal)
		{
			weights[index] = newVal;
		}

		public double GetWeight(int index)
		{
			return weights[index];
		}
	
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?