Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 14, 2018 17:34
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/054887fe8867175c04303c786042bcb7 to your computer and use it in GitHub Desktop.
Save NMZivkovic/054887fe8867175c04303c786042bcb7 to your computer and use it in GitHub Desktop.
public class VisibleLayer : Layer
{
public VisibleLayer(int numberOfNeurons) : base(numberOfNeurons)
{
}
public override void CalculateCDState()
{
foreach (var neuron in Neurons)
{
var probability = _sigmoid.CalculateOutput(neuron.Outputs.Where(x => x.InputNeruon.CDState).Sum(y => y.Weight));
neuron.CDState = probability < _random.NextDouble();
}
}
public void PushValuesToInput(bool[] input)
{
if (input.Length != Neurons.Count)
{
throw new ArgumentException("Input has invalid size");
}
for (int i = 0; i < input.Length; i++)
{
Neurons[i].State = input[i];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment