コード例 #1
0
        public IntegerFastConcurrentNetwork(int biasNeuronCount, 
            int inputNeuronCount,
            int outputNeuronCount,
            int totalNeuronCount,
            IntegerFastConnection[] connectionArray)
        {
            this.biasNeuronCount = biasNeuronCount;
            this.inputNeuronCount = inputNeuronCount;
            this.totalInputNeuronCount = biasNeuronCount + inputNeuronCount;
            this.outputNeuronCount = outputNeuronCount;

            this.connectionArray = connectionArray;

            //----- Allocate the arrays that make up the neural network.
            // The neuron signals are initialised to 0 by default. Only bias nodes need setting to 1.
            neuronSignalArray = new int[totalNeuronCount];
            _neuronSignalArray = new int[totalNeuronCount];

            for(int i=0; i<biasNeuronCount; i++)
                neuronSignalArray[i] = 0x1000;
        }
コード例 #2
0
		// This is a quick sort algorithm that manipulates FastConnection structures. Although this
		// is the same sorting technique used internally by Array.Sort this is approximately 10 times 
		// faster because it eliminates the need for boxing and unboxing of the structs.
		// So although this code could be replcaed by a single Array.Sort statement, the pay off
		// was though to be worth it.

		private static int CompareKeys(ref IntegerFastConnection a, ref IntegerFastConnection b)
		{
			int diff = a.sourceNeuronIdx - b.sourceNeuronIdx;
			if(diff==0)
			{
				// Secondary sort on targetNeuronIdx.
				return a.targetNeuronIdx - b.targetNeuronIdx;
			}
			else
			{
				return diff;
			}
		}