2using System.Collections.Generic;
26 [TypeConverter(typeof(ExpandableObjectConverter))]
29 bool m_bEnableCentroidUpdate =
true;
30 int m_nCentroidOutputIteration = 300;
31 bool m_bOutputCentroids =
false;
32 List<int> m_rgIgnoreLabels =
new List<int>();
34 int m_nCacheSize = 100;
36 double m_dfPreGenAlpha = 1.1;
37 int m_nPreGenerateTargetCount = 0;
66 [Description(
"Specifies the pregen margin.")]
69 get {
return m_dfPreGenAlpha; }
70 set { m_dfPreGenAlpha = value; }
82 [Description(
"Specifies the pre-generate target count, only used when 'target' = PREGEN.")]
85 get {
return m_nPreGenerateTargetCount; }
86 set { m_nPreGenerateTargetCount = value; }
92 [Description(
"Specifies whether or not to update the centroids. For example in some cases a fixed centroid may be desired, such as in the case when initializing centroids with a PREGEN value.")]
95 get {
return m_bEnableCentroidUpdate; }
96 set { m_bEnableCentroidUpdate = value; }
102 [Description(
"Specifies the iteration where calculated centroids are output for each label, before this value, the centroids should not be used for their calculation is not complete (default = 300).")]
105 get {
return m_nCentroidOutputIteration; }
106 set { m_nCentroidOutputIteration = value; }
112 [Description(
"Optionally, specifies to output the centroids in top[1] (default = false).")]
115 get {
return m_bOutputCentroids; }
116 set { m_bOutputCentroids = value; }
122 [Description(
"Optionally, specifies one or more labels to ignore. (default = none, which then expects all labels).")]
125 get {
return m_rgIgnoreLabels; }
126 set { m_rgIgnoreLabels = value; }
132 [Description(
"Optionally, specifies the target type to use (default = CENTROID).")]
135 get {
return m_target; }
136 set { m_target = value; }
142 [Description(
"Specifies the size of the cache (in number of batches) used when calculating the CENTROID and KNN values (default = 300).")]
145 get {
return m_nCacheSize; }
146 set { m_nCacheSize = value; }
152 [Description(
"Optionally, specifies the K value to use with the KNN target (default = 5).")]
156 set { m_nK = value; }
165 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
183 m_nCentroidOutputIteration = p.m_nCentroidOutputIteration;
184 m_nCacheSize = p.m_nCacheSize;
185 m_bOutputCentroids = p.m_bOutputCentroids;
186 m_dfPreGenAlpha = p.m_dfPreGenAlpha;
187 m_nPreGenerateTargetCount = p.m_nPreGenerateTargetCount;
188 m_bEnableCentroidUpdate = p.m_bEnableCentroidUpdate;
190 if (p.m_rgIgnoreLabels !=
null)
191 m_rgIgnoreLabels =
Utility.Clone<
int>(p.m_rgIgnoreLabels);
193 m_target = p.m_target;
221 rgChildren.
Add(
"target",
target.ToString());
224 rgChildren.
Add(
"k",
k.ToString());
228 rgChildren.Add(
"ignore_label", nLabel.ToString());
231 return new RawProto(strName,
"", rgChildren);
244 if ((strVal = rp.
FindValue(
"centroid_output_iteration")) !=
null)
247 if ((strVal = rp.
FindValue(
"enable_centroid_update")) !=
null)
250 if ((strVal = rp.
FindValue(
"cache_size")) !=
null)
253 if ((strVal = rp.
FindValue(
"output_centroids")) !=
null)
256 if ((strVal = rp.
FindValue(
"pregen_alpha")) !=
null)
259 if ((strVal = rp.
FindValue(
"pregen_label_count")) !=
null)
264 foreach (
RawProto rplabel
in rpIgnore)
266 int nLabel =
int.Parse(rplabel.
Value);
267 if (!p.ignore_labels.Contains(nLabel))
268 p.ignore_labels.
Add(nLabel);
271 if ((strVal = rp.FindValue(
"target")) !=
null)
273 if (strVal ==
TARGET.KNN.ToString())
275 else if (strVal ==
TARGET.PREGEN.ToString())
278 p.target =
TARGET.CENTROID;
281 if ((strVal = rp.FindValue(
"k")) !=
null)
282 p.k =
int.Parse(strVal);
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.
string Value
Get/set the value of the node.
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
RawProtoCollection FindChildren(params string[] rgstrName)
Searches for all children with a given name in this node's children.
The Utility class provides general utility funtions.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the DecodeLayer and the AccuracyEncodingLayer.
DecodeParameter()
Constructor for the parameter.
bool output_centroids
Optionally, specifies to output the centroids in top[1] (default = false).
override void Copy(LayerParameterBase src)
Copy on parameter to another.
bool enable_centroid_update
Specifies whether or not to update the centroids. For example in some cases a fixed centroid may be d...
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
int centroid_output_iteration
Specifies the iteration where calculated centroids are output for each label, before this value,...
static DecodeParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
double pregen_alpha
Specifies the pregen margin.
TARGET
Defines the target type.
int cache_size
Specifies the size of the cache (in number of batches) used when calculating the CENTROID and KNN val...
int pregen_label_count
Specifies the pre-generate target count, only used when 'target' = PREGEN.
TARGET target
Optionally, specifies the target type to use (default = CENTROID).
int k
Optionally, specifies the K value to use with the KNN target (default = 5).
List< int > ignore_labels
Optionally, specifies one or more labels to ignore. (default = none, which then expects all labels).
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.param.beta parameters are used by the MyCaffe.layer.beta layers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...