-
Notifications
You must be signed in to change notification settings - Fork 1
/
Link.cs
46 lines (39 loc) · 1006 Bytes
/
Link.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
using System;
using System.Collections.Generic;
using System.Linq;
namespace chainer
{
public class Link
{
public Dictionary<string, Variable> _Params = new Dictionary<string, Variable>();
public Link(Dictionary<string, Variable> @params)
{
_Params = @params;
}
protected Link()
{
}
public virtual IEnumerable<Variable> GetParams()
{
return _Params.Values.AsEnumerable();
}
public void ClearGrads()
{
foreach (var param in GetParams())
{
param.ClearGrad();
}
}
public virtual Variable Forward(Variable x)
{
throw new NotImplementedException();
}
public virtual void Serialize(serializers.Serializer serializer)
{
foreach (var kv in _Params)
{
serializer.Communicate(kv.Key, kv.Value);
}
}
}
}