MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MeanErrorLossParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7using MyCaffe.common;
8
9namespace MyCaffe.param
10{
20 [Serializable]
21 [TypeConverter(typeof(ExpandableObjectConverter))]
23 {
24 int m_nAxis = 1; // Axis used to calculate the loss normalization.
25 MEAN_ERROR m_meanErrorType = MEAN_ERROR.MAE; // default to the Mean Absolute Error.
26
27
30 {
31 }
32
36 [Description("Specifies the axis of the probability, default = 1")]
37 public int axis
38 {
39 get { return m_nAxis; }
40 set { m_nAxis = value; }
41 }
42
47 {
48 get { return m_meanErrorType; }
49 set { m_meanErrorType = value; }
50 }
51
53 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
54 {
55 RawProto proto = RawProto.Parse(br.ReadString());
57
58 if (!bNewInstance)
59 Copy(p);
60
61 return p;
62 }
63
65 public override void Copy(LayerParameterBase src)
66 {
68 m_nAxis = p.m_nAxis;
69 m_meanErrorType = p.m_meanErrorType;
70 }
71
73 public override LayerParameterBase Clone()
74 {
76 p.Copy(this);
77 return p;
78 }
79
85 public override RawProto ToProto(string strName)
86 {
87 RawProtoCollection rgChildren = new RawProtoCollection();
88
89 rgChildren.Add("axis", axis.ToString());
90 rgChildren.Add("mean_error_type", mean_error_type.ToString());
91
92 return new RawProto(strName, "", rgChildren);
93 }
94
101 {
102 string strVal;
104
105 if ((strVal = rp.FindValue("axis")) != null)
106 p.axis = int.Parse(strVal);
107
108 if ((strVal = rp.FindValue("mean_error_type")) != null)
109 {
110 switch (strVal)
111 {
112 case "MSE":
114 break;
115 case "MAE":
117 break;
118 default:
119 throw new Exception("The mean _error_type parameter must be one of the following: MSE, MAE");
120 }
121 }
122
123 return p;
124 }
125 }
126}
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 for the MeanErrorLossLayerParameter.
MEAN_ERROR mean_error_type
[optional, default = MSE] Specifies the type of mean error to use.
MeanErrorLossParameter()
Constructor for the parameter.
static MeanErrorLossParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int axis
[optional, default = 1] Specifies the axis of the probability.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
MEAN_ERROR
Defines the type of Mean Error to use.
Definition: CudaDnn.cs:37
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-...
Definition: Annotation.cs:12