MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
HingeLossParameter.cs
1using System;
2using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
24 public enum Norm
25 {
29 L1 = 1,
33 L2 = 2
34 }
35
36 Norm m_norm = Norm.L1;
37
40 {
41 }
42
46 [Description("Specify the Norm to use: L1 or L2")]
47 public Norm norm
48 {
49 get { return m_norm; }
50 set { m_norm = value; }
51 }
52
54 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
55 {
56 RawProto proto = RawProto.Parse(br.ReadString());
58
59 if (!bNewInstance)
60 Copy(p);
61
62 return p;
63 }
64
66 public override void Copy(LayerParameterBase src)
67 {
69 m_norm = p.m_norm;
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("norm", norm.ToString());
90
91 return new RawProto(strName, "", rgChildren);
92 }
93
100 {
101 string strVal;
103
104 if ((strVal = rp.FindValue("norm")) != null)
105 {
106 switch (strVal)
107 {
108 case "L1":
109 p.norm = Norm.L1;
110 break;
111
112 case "L2":
113 p.norm = Norm.L2;
114 break;
115
116 default:
117 throw new Exception("Unknown 'norm' value: " + strVal);
118 }
119 }
120
121 return p;
122 }
123 }
124}
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
Specifies the parameters for the HingLossLayer.
static HingeLossParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
Norm norm
Specify the Norm to use L1 or L2
HingeLossParameter()
Constructor for the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Norm
Defines the type of normalization.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
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