-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeuron.cs
More file actions
69 lines (62 loc) · 1.54 KB
/
Copy pathNeuron.cs
File metadata and controls
69 lines (62 loc) · 1.54 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
56
57
58
59
60
61
62
63
64
65
66
67
68
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
namespace xorc
{
public class Neuron{
public List<int> inputEdges;
public List<int> outputEdges;
public int inputCounter;
public double sumWV;
public double value;
public Neuron()
{
inputEdges = new List<int> ();
outputEdges = new List<int> ();
value = 0.0;
sumWV = 0.0;
inputCounter = 0;
}
/*public void reset()
{
value = 0.0;
int disabled = 0;
for (int i=0; i<inputEdges.Count; i++) {
if (!inputEdges [i].isEnabled) {
disabled++;
}
}
inputCounter = inputEdges.Count - disabled;
sumWV = 0.0;
}*/
public void addInput(int e){
inputEdges.Add (e);
}
public void addOutput(int e){
outputEdges.Add (e);
}
//adds signal from input, reduces number of inputs not yet added
public void addValue (double value, double weight){
sumWV += value * weight;
inputCounter--;
}
public void computeValue()
{
if (sumWV > 350.0) {
sumWV = 350.0;
}
double e2z = Math.Pow (Math.E, 2.0 * sumWV);
value = (e2z - 1.0) / (e2z + 1.0);
//value = 1.0 / (1.0 + Math.Pow (Math.E, -4.9 * sumWV));
}
}
}