-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetFileData.cs
More file actions
68 lines (57 loc) · 1.58 KB
/
NetFileData.cs
File metadata and controls
68 lines (57 loc) · 1.58 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NN
{
struct WeightImage
{
public double Data;
public int SourceIndex;
public int DestinationIndex;
}
public class NetFileData
{
private List<List<WeightImage>> weights = new List<List<WeightImage>>();
private List<int> neurons = new List<int>();
public double Temperature
{
get;
private set;
}
public double Threshold
{
get;
private set;
}
public int LayerCount
{
get;
private set;
}
public int GetLayerSize(int layer)
{
return neurons[layer];
}
public void AddWeights(int layer, int destination, int source, double w)
{
var list = weights[layer] == null ? (weights[layer] = new List<WeightImage>()) : weights[layer];
list.Add(new WeightImage() { DestinationIndex = destination, SourceIndex = source, Data = w });
}
public double GetWeights(int layer, int destination, int source)
{
var query = from wi in weights[layer]
where wi.SourceIndex == source && wi.DestinationIndex == destination
select wi.Data;
double? val = query.FirstOrDefault();
if (val.HasValue)
{
return val.Value;
}
else
{
return 0.0;
}
}
}
}