コード例 #1
0
ファイル: Node.cs プロジェクト: ZZhouCNAnhui/Neat-for-C-Sharp
 public Node(NodeGemone g, Network network)
 {
     this.network = network;
     bias         = g.b;
     this.Type    = g.Type;
     ID           = g.ID;
 }
コード例 #2
0
        /// <summary>
        /// 生成基因
        /// </summary>
        /// <param name="inputL">基因神经网络输入数量</param>
        /// <param name="outputL">基因神经网络输出数量</param>
        public Genome(int inputL, int outputL)
        {
            baoluizhi   = inputL + outputL;
            nodeGemones = new NodeGemone[baoluizhi];
            for (int i = 0; i < inputL; i++)
            {
                nodeGemones[i]      = new NodeGemone();
                nodeGemones[i].b    = 0;
                nodeGemones[i].ID   = i;
                nodeGemones[i].Type = NodeType.Input;
            }
            for (int i = inputL; i < outputL + inputL; i++)
            {
                nodeGemones[i]      = new NodeGemone();
                nodeGemones[i].b    = 0;
                nodeGemones[i].ID   = i;
                nodeGemones[i].Type = NodeType.Output;
            }

            LinkGenones = new bool[baoluizhi, baoluizhi];
            LinkWs      = new float[baoluizhi, baoluizhi];
            for (int inp = 0; inp < baoluizhi; inp++)
            {
                for (int outp = 0; outp < baoluizhi; outp++)
                {
                    if (nodeGemones[inp].Type == NodeType.Input &&
                        nodeGemones[outp].Type == NodeType.Output)
                    {
                        LinkGenones[inp, outp] = true;
                    }
                }
            }

            Random r = new Random();

            LinkWs = new float[baoluizhi, baoluizhi];
            for (int i = 0; i < baoluizhi; i++)
            {
                for (int j = 0; j < baoluizhi; j++)
                {
                    LinkWs[i, j] = (float)(r.NextDouble() * 2);
                }
            }
        }