Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active October 14, 2018 17:25
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/15712b9e785b377b632e2cbc2a59128d to your computer and use it in GitHub Desktop.
Save NMZivkovic/15712b9e785b377b632e2cbc2a59128d to your computer and use it in GitHub Desktop.
public abstract class Layer
{
public List<INeuron> Neurons { get; }
protected Sigmoid _sigmoid;
protected Random _random;
public Layer(int numberOfNeurons)
{
Neurons = new List<INeuron>();
_random = new Random();
for (int i = 0; i < numberOfNeurons; i++)
{
Neurons.Add(new Neuron(GenerateRandomBool(), _random.NextDouble()));
}
}
public void ConnectLayers(Layer layer)
{
foreach(var thisNeuron in this.Neurons)
{
foreach(var layerNeruon in layer.Neurons)
{
layerNeruon.AddInputNeuron(thisNeuron, _random.NextDouble());
}
}
}
private bool GenerateRandomBool()
{
return _random.NextDouble() > 0.5;
}
public abstract void CalculateCDState();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment