public void ShouldProduceActivation()
        {
            _activationFunction.Activate(Arg.Is <double>(x => x == 21)).Returns(1);
            _activationFunction.Activate(Arg.Is <double>(x => x == 26)).Returns(5);
            _activationFunction.Activate(Arg.Is <double>(x => x == 31)).Returns(3);

            var fullyConnectedLayer = new FullyConnectedLayer(_activationFunction, new double[] { 1, 2, 3, 3, 2, 1, 1, 2, 3 }, new double[] { 1, 2, 3 });

            fullyConnectedLayer.Produce(new double[] { 3, 4, 5 });
            fullyConnectedLayer.Activations.Should().NotBeNull();
            fullyConnectedLayer.Activations.Should().ContainInOrder(new double[] { 1, 5, 3 });
            _activationFunction.Received(3).Activate(Arg.Any <double>());
        }
示例#2
0
 public void Update()
 {
     var dotProduct = Inputs.Select(kvp => kvp.Value)
         .Sum(synapse => synapse.Input.GetValue()*synapse.Weight);
     double output = _activationFunction.Activate(dotProduct);
     _cachedOutput = output;
 }
示例#3
0
    public void FeedForward(Layer prevLayer)
    {
        float sum = 0f;

        foreach (var neuron in prevLayer)
        {
            float val    = neuron.GetOutputValue();
            float weight = neuron._outputWeights[_myIndex];
            sum += val * weight;
        }
        _output = _transfer.Activate(sum);
    }
示例#4
0
        public double Activate(double[] inputSignals)
        {
            if (inputSignals.Length != Weights.Length)
            {
                throw new Exception("Neuron weights number must be the same as input signals number passed to it");
            }

            OutputSignal = default(double);

            for (var i = 0; i < inputSignals.Length; i++)
            {
                InputSignals[i] = inputSignals[i];
                OutputSignal   += inputSignals[i] * Weights[i];
            }

            return(_activationFunction.Activate(OutputSignal));
        }
示例#5
0
文件: Neuron.cs 项目: VVK-3/nnsharp
 public double Output()
 {
     return(transferFunc.Activate(NetValue));
 }
 public void FeedForward(Array <float> feed)
 {
     _target.SumVector    = NumMath.SumColumn(feed.H * _target.KnowlodgeMatrix) + _target.BiasVector;
     _target.OutputVector = _activationFunction.Activate(_target.SumVector);
 }
 public virtual void Activate()
 {
     _target.OutputVector = _activationFunction.Activate(_target.SumVector);
 }