Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Zytek committed Dec 17, 2014
1 parent 33802be commit 3642f5b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions NumberRecognizer/NumberRecognizer.Lib/Network/HiddenNeuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HiddenNeuron : INeuron, ICacheable
/// </summary>
public HiddenNeuron()
{
InputLayer = new List<WeightedLink>();
this.InputLayer = new List<WeightedLink>();
}

/// <summary>
Expand All @@ -43,24 +43,24 @@ public double ActivationValue
{
get
{
if (!cachedActivationValue.HasValue)
if (!this.cachedActivationValue.HasValue)
{
//double sum = InputLayer.Sum(x => x.Neuron.ActivationValue * x.Weight);
//performance better than LINQ Sum
////double sum = InputLayer.Sum(x => x.Neuron.ActivationValue * x.Weight);

////performance better than LINQ Sum
double sum = 0.0;

foreach (WeightedLink link in InputLayer)
{
sum += link.Neuron.ActivationValue * link.Weight;
}

//Sigmoid
//return ((1 / (1 + Math.Pow(Math.E, sum * -1))) * 2) - 1;
cachedActivationValue = ((1 / (1 + Math.Exp(sum * -1))) * 2) - 1;
////Sigmoid
////return ((1 / (1 + Math.Pow(Math.E, sum * -1))) * 2) - 1;
this.cachedActivationValue = ((1 / (1 + Math.Exp(sum * -1))) * 2) - 1;
}

return cachedActivationValue.Value;
return this.cachedActivationValue.Value;
}
}

Expand All @@ -77,7 +77,7 @@ public double ActivationValue
/// </summary>
public void ResetCachedValue()
{
cachedActivationValue = null;
this.cachedActivationValue = null;
}
}
}

0 comments on commit 3642f5b

Please sign in to comment.