-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeuralLayer.cs
More file actions
55 lines (49 loc) · 1.26 KB
/
NeuralLayer.cs
File metadata and controls
55 lines (49 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlothNet
{
class NeuralLayer
{
public List<Neuron> Neurons { get; set; }
public string Name { get; set; }
public double Weight { get; set; }
public NeuralLayer(int count, double initWeight, string name = "NetworkLayer")
{
Neurons = new List<Neuron>();
for(int i = 0; i < count; i++)
{
Neurons.Add(new Neuron());
}
Weight = initWeight;
Name = name;
}
public void Compute(double error) // lr = learning rate
{
foreach (Neuron n in Neurons)
{
n.AdjustWeight(error);
}
}
public void Forward()
{
foreach(Neuron n in Neurons)
{
n.Fire();
}
}
public void Optimise(double lr, double error, double delta)
{
foreach(Neuron n in Neurons)
{
n.AdjustWeight(error);
}
}
public void Display()
{
Console.WriteLine("Layer: {0}, Weight: {1}", Name, Weight);
}
}
}