2using System.Collections.Generic;
17 [TypeConverter(typeof(ExpandableObjectConverter))]
22 List<int> m_rgnIgnoreLabel =
new List<int>();
23 bool m_bEnableSimpleAccuracy =
false;
24 bool m_bEnableLastElementOnly =
false;
34 [Description(
"Enables a simple argmax based accuracy calculation where the argmax is compared with the actual.")]
37 get {
return m_bEnableSimpleAccuracy; }
38 set { m_bEnableSimpleAccuracy = value; }
44 [Description(
"When computing accuracy, only count the last element of the prediction blob.")]
47 get {
return m_bEnableLastElementOnly; }
48 set { m_bEnableLastElementOnly = value; }
56 [Description(
"When computing accuracy, count as correct by comparing the true label to the 'top_k' scoring classes. By default, only compare the top scoring class (i.e. argmax).")]
59 get {
return m_nTopK; }
60 set { m_nTopK = value; }
70 [Description(
"Specifies the 'label' axis of the prediction blob, whos argmax corresponds to the predicted label -- may be negative to index from the end (e.g., -1 for the last axis). For example, if axis == 1 and the predictions are (NxCxHxW), the label blob is expected to contain N*H*W ground truth labels with integer values in {0, 1,..., C-1}.")]
73 get {
return m_nAxis; }
74 set { m_nAxis = value; }
80 [Description(
"If specified, ignore instances with the given label(s).")]
83 get {
return m_rgnIgnoreLabel; }
87 m_rgnIgnoreLabel.Clear();
89 m_rgnIgnoreLabel = value;
100 return m_rgnIgnoreLabel.Contains(nLabel);
104 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
121 m_bEnableSimpleAccuracy = p.m_bEnableSimpleAccuracy;
122 m_bEnableLastElementOnly = p.m_bEnableLastElementOnly;
123 m_rgnIgnoreLabel =
Utility.Clone<
int>(p.m_rgnIgnoreLabel);
144 rgChildren.
Add(
"top_k",
top_k.ToString());
147 rgChildren.
Add(
"axis",
axis.ToString());
155 if (m_rgnIgnoreLabel.Count > 0)
157 if (m_rgnIgnoreLabel.Count == 1)
158 rgChildren.
Add(
"ignore_label", m_rgnIgnoreLabel[0]);
160 rgChildren.
Add(
"ignore_labels",
Utility.ToString<
int>(m_rgnIgnoreLabel));
163 return new RawProto(strName,
"", rgChildren);
176 if ((strVal = rp.
FindValue(
"top_k")) !=
null)
177 p.
top_k = uint.Parse(strVal);
179 if ((strVal = rp.
FindValue(
"axis")) !=
null)
180 p.
axis =
int.Parse(strVal);
182 if ((strVal = rp.
FindValue(
"enable_simple_accuracy")) !=
null)
185 if ((strVal = rp.
FindValue(
"enable_last_element_only")) !=
null)
188 if ((strVal = rp.
FindValue(
"ignore_label")) !=
null)
194 if ((strVal = rp.
FindValue(
"ignore_labels")) !=
null)
198 string[] rgstr = strVal.Trim(
' ',
'{',
'}').Split(
',');
200 foreach (
string str
in rgstr)
202 if (!
string.IsNullOrEmpty(str))
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.
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.
The Utility class provides general utility funtions.
Specifies the parameters for the AccuracyLayer.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
uint top_k
When computing accuracy, count as correct by comparing the true label to the top_k scoring classes....
AccuracyParameter()
Constructor for the parameter.
List< int > ignore_labels
If specified, ignore instances with the given label(s).
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int axis
The 'label' axis of the prediction blob, whos argmax corresponds to the predicted label – may be nega...
bool IgnoreLabel(int nLabel)
Returns 'true' if the label is to be ignored.
bool enable_simple_accuracy
Enables a simple accuracy calculation where the argmax is compared with the actual.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
static AccuracyParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
bool enable_last_element_only
When computing accuracy, only count the last element of the prediction blob.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...