Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 14, 2018 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/ed1bf09615c03af34d3f068fc35abde5 to your computer and use it in GitHub Desktop.
Save NMZivkovic/ed1bf09615c03af34d3f068fc35abde5 to your computer and use it in GitHub Desktop.
public class HiddenLayer : Layer
{
public HiddenLayer(int numberOfNeurons) : base(numberOfNeurons)
{ }
public void CalculateState()
{
foreach(var neuron in Neurons)
{
var probability = _sigmoid.CalculateOutput(neuron.Inputs.Where(x => x.InputNeruon.State).Sum(y => y.Weight));
neuron.State = probability < _random.NextDouble();
}
}
public override void CalculateCDState()
{
foreach (var neuron in Neurons)
{
var probability = _sigmoid.CalculateOutput(neuron.Inputs.Where(x => x.InputNeruon.CDState).Sum(y => y.Weight));
neuron.CDState = probability < _random.NextDouble();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment