Пример #1
0
        /// <summary>
        /// Constructs a CyclicNetwork with the provided neural net definition.
        /// </summary>
        public NeuralNetCyclic(
            DirectedGraph digraph,
            double[] weightArr,
            VecFnSegment2 <double> activationFn,
            int cyclesPerActivation)
        {
            Debug.Assert(digraph.ConnectionIdArrays._sourceIdArr.Length == weightArr.Length);

            // Store refs to network structure data.
            _srcIdArr  = digraph.ConnectionIdArrays._sourceIdArr;
            _tgtIdArr  = digraph.ConnectionIdArrays._targetIdArr;
            _weightArr = weightArr;

            // Store network activation function and parameters.
            _activationFn        = activationFn;
            _cyclesPerActivation = cyclesPerActivation;

            // Store input/output node counts.
            _inputCount  = digraph.InputCount;
            _outputCount = digraph.OutputCount;

            // Create node pre- and post-activation signal arrays.
            int nodeCount = digraph.TotalNodeCount;

            _preActivationArr  = new double[nodeCount];
            _postActivationArr = new double[nodeCount];

            // Wrap sub-ranges of the neuron signal arrays as input and output vectors.
            this.InputVector = new VectorSegment <double>(_postActivationArr, 0, _inputCount);

            // Note. Output neurons follow input neurons in the arrays.
            this.OutputVector = new VectorSegment <double>(_postActivationArr, _inputCount, _outputCount);
        }
        private void RunBenchmark(IActivationFunction <double> actFn)
        {
            VecFnSegment2 <double> fn = actFn.Fn;

            for (int i = 0; i < __loops; i++)
            {
                fn(_x, _w, 0, _x.Length);
            }
        }
Пример #3
0
 /// <summary>
 /// Constructs a CyclicNetwork with the provided neural net definition.
 /// </summary>
 public NeuralNetCyclic(
     WeightedDirectedGraph <double> digraph,
     VecFnSegment2 <double> activationFn,
     int cyclesPerActivation)
     : this(
         digraph,
         digraph.WeightArray,
         activationFn,
         cyclesPerActivation)
 {
 }
 /// <summary>
 /// Constructs a CyclicNetwork with the provided neural net definition.
 /// </summary>
 public CyclicNeuralNet(
     WeightedDirectedGraph <double> digraph,
     VecFnSegment2 <double> activationFn,
     int activationCount,
     bool boundedOutput)
     : this(
         digraph,
         digraph.WeightArray,
         activationFn,
         activationCount,
         boundedOutput)
 {
 }
Пример #5
0
        /// <summary>
        /// Constructs a CyclicNetwork with the provided neural net definition parameters.
        /// </summary>
        public CyclicNeuralNet(
            WeightedDirectedGraph <double> digraph,
            VecFnSegment2 <double> activationFn,
            int activationCount,
            bool boundedOutput)
        {
            // Store refs to network structure data.
            _srcIdArr  = digraph.ConnectionIdArrays._sourceIdArr;
            _tgtIdArr  = digraph.ConnectionIdArrays._targetIdArr;
            _weightArr = digraph.WeightArray;

            // Store network activation function and parameters.
            _activationFn    = activationFn;
            _activationCount = activationCount;

            // Store input/output node counts.
            _inputCount  = digraph.InputCount;
            _outputCount = digraph.OutputCount;

            // Create node pre- and post-activation signal arrays.
            int nodeCount = digraph.TotalNodeCount;

            _preActivationArr  = new double[nodeCount];
            _postActivationArr = new double[nodeCount];

            // Wrap sub-ranges of the neuron signal arrays as input and output vectors.
            _inputVector = new VectorSegment <double>(_postActivationArr, 0, _inputCount);

            // Note. Output neurons follow input neurons in the arrays.
            var outputVec = new VectorSegment <double>(_postActivationArr, _inputCount, _outputCount);

            if (boundedOutput)
            {
                _outputVector = new BoundedVector(outputVec);
            }
            else
            {
                _outputVector = outputVec;
            }
        }