-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnection.cs
52 lines (45 loc) · 1.64 KB
/
Connection.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace C_EcoSimApp
{
internal class Connection
{
public string InputOrHiddenLayer;
public string HiddenLayerOrOutput;
public int connectionStart;
public int connectionEnd;
public float weight;
public float bias;
public float optionStart;
public float optionEnd;
public Connection(string cs, string ce, string w, string b, string os, string oe) {
if (cs != "")
{
if (cs[0].ToString() == "0")
{
InputOrHiddenLayer = "Input";
}
else InputOrHiddenLayer = "HiddenLayer";
if (ce[0].ToString() == "0")
{
HiddenLayerOrOutput = "HiddenLayer";
}
else HiddenLayerOrOutput = "Output";
connectionStart = Convert.ToInt32(cs.Substring(1), 2);
connectionEnd = Convert.ToInt32(ce.Substring(1), 2);
weight = (float)Convert.ToInt32(w, 2) / 64 - 1;
bias = (float)Convert.ToInt32(b, 2) / 64 - 1;
optionStart = (float)Convert.ToInt32(os, 2);
optionEnd = (float)Convert.ToInt32(oe, 2);
}
}
public string REPR()
{
return $"Connection from: {InputOrHiddenLayer}({connectionStart}) to {HiddenLayerOrOutput}({connectionEnd}).\n\tWeight: {weight}, \n\tBias: {bias};\n";
}
}
}