MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
OneHotParameter.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace MyCaffe.param.nt
10{
33 [Serializable]
34 [TypeConverter(typeof(ExpandableObjectConverter))]
36 {
37 int m_nAxis = 2;
38 uint m_nNumOutput = 16;
39 double m_dfMin = -1.0;
40 double m_dfMax = 1.0;
41 int m_nMinAxes = 4;
42
47 {
48 }
49
53 [Description("Specifies the axis over which to apply the one-hot vectoring.")]
54 public int axis
55 {
56 get { return m_nAxis; }
57 set { m_nAxis = value; }
58 }
59
63 [Description("Specifies the minimum number of axes. Axes of size 1 are added to the current axis count up to the minimum.")]
64 public int min_axes
65 {
66 get { return m_nMinAxes; }
67 set { m_nMinAxes = value; }
68 }
69
73 [Description("Specifies the number of items within the one-hot vector output.")]
74 public uint num_output
75 {
76 get { return m_nNumOutput; }
77 set { m_nNumOutput = value; }
78 }
79
83 [Description("Specifies the minimum data range over which to bucketize for the one-hot vector input.")]
84 public double min
85 {
86 get { return m_dfMin; }
87 set { m_dfMin = value; }
88 }
89
93 [Description("Specifies the maximum data range over which to bucketize for the one-hot vector input.")]
94 public double max
95 {
96 get { return m_dfMax; }
97 set { m_dfMax = value; }
98 }
99
106 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
107 {
108 RawProto proto = RawProto.Parse(br.ReadString());
109 OneHotParameter p = FromProto(proto);
110
111 if (!bNewInstance)
112 Copy(p);
113
114 return p;
115 }
116
121 public override void Copy(LayerParameterBase src)
122 {
124
125 m_nAxis = p.m_nAxis;
126 m_nNumOutput = p.m_nNumOutput;
127 m_dfMin = p.m_dfMin;
128 m_dfMax = p.m_dfMax;
129 m_nMinAxes = p.m_nMinAxes;
130 }
131
136 public override LayerParameterBase Clone()
137 {
139 p.Copy(this);
140 return p;
141 }
142
148 public override RawProto ToProto(string strName)
149 {
150 RawProtoCollection rgChildren = new RawProtoCollection();
151
152 rgChildren.Add("axis", axis.ToString());
153 rgChildren.Add("num_output", num_output.ToString());
154 rgChildren.Add("min", min.ToString());
155 rgChildren.Add("max", max.ToString());
156 rgChildren.Add("min_axes", min_axes.ToString());
157
158 return new RawProto(strName, "", rgChildren);
159 }
160
167 {
168 string strVal;
170
171 if ((strVal = rp.FindValue("axis")) != null)
172 p.axis = int.Parse(strVal);
173
174 if ((strVal = rp.FindValue("num_output")) != null)
175 p.num_output = uint.Parse(strVal);
176
177 if ((strVal = rp.FindValue("min")) != null)
178 p.min = ParseDouble(strVal);
179
180 if ((strVal = rp.FindValue("max")) != null)
181 p.max = ParseDouble(strVal);
182
183 if ((strVal = rp.FindValue("min_axes")) != null)
184 p.min_axes = int.Parse(strVal);
185
186 return p;
187 }
188 }
189}
static double ParseDouble(string strVal)
Parse double values using the US culture if the decimal separator = '.', then using the native cultur...
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters used by the OneHotLayer
static OneHotParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
double min
Specifies the minimum data range over which to bucketize for the one-hot vector input.
uint num_output
Specifies the number of items within the one-hot vector output.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
double max
Specifies the maximum data range over which to bucketize for the one-hot vector input.
int min_axes
Specifies the minimum number of axes. Axes of size 1 are added to the current axis count up to the mi...
int axis
Specifies the axis over which to apply the one-hot vectoring.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.nt namespace defines the parameters used by the Nerual Style Transfer layers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12