2using System.Collections.Generic;
25 [TypeConverter(typeof(ExpandableObjectConverter))]
28 double m_dfMargin = 1.0;
29 bool m_bLegacyVersion =
false;
30 bool m_bOutputMatches =
false;
31 double m_dfMatchingDistScale = 1.0;
84 [Description(
"Specifies the margin for dissimilar pair.")]
87 get {
return m_dfMargin; }
88 set { m_dfMargin = value; }
101 [Description(
"Specifies to use the legacy version or not. When true the legacy version '(margin - d^2)' is used. Otherwise the default is to use the version '(margin - d)^2' proposed in the Hadsell paper.")]
105 get {
return m_bLegacyVersion; }
106 set { m_bLegacyVersion = value; }
112 [Description(
"Optionally, specifies to output match information (default = false).")]
115 get {
return m_bOutputMatches; }
116 set { m_bOutputMatches = value; }
122 [Description(
"Optionally, specifies to use centroid learning as soon as the centroids (from the DecodeLayer) are ready - e.g. they have an asum > 0 (default = false, meaning no centroid learning occurs).")]
125 get {
return m_centroidLearning; }
126 set { m_centroidLearning = value; }
132 [Description(
"Optionally, specifies the distance calculation to use when calculating the distance between encoding pairs (default = EUCLIDEAN).")]
135 get {
return m_distanceCalc; }
136 set { m_distanceCalc = value; }
142 [Description(
"Optionally, specifies the scaling applied to distances between matching pairs (default = 1.0, which ignores the scaling).")]
145 get {
return m_dfMatchingDistScale; }
146 set { m_dfMatchingDistScale = value; }
150 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
165 m_dfMargin = p.m_dfMargin;
166 m_bLegacyVersion = p.m_bLegacyVersion;
167 m_bOutputMatches = p.m_bOutputMatches;
168 m_centroidLearning = p.m_centroidLearning;
169 m_distanceCalc = p.m_distanceCalc;
170 m_dfMatchingDistScale = p.m_dfMatchingDistScale;
191 rgChildren.
Add(
"margin",
margin.ToString());
205 return new RawProto(strName,
"", rgChildren);
218 if ((strVal = rp.
FindValue(
"margin")) !=
null)
221 if ((strVal = rp.
FindValue(
"legacy_version")) !=
null)
224 if ((strVal = rp.
FindValue(
"output_matches")) !=
null)
227 if ((strVal = rp.
FindValue(
"centroid_learning")) !=
null)
237 if ((strVal = rp.
FindValue(
"distance_calculation")) !=
null)
243 if ((strVal = rp.
FindValue(
"matching_distance_scale")) !=
null)
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.
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.
Specifies the parameters for the ContrastiveLossLayer.
bool output_matches
Optionally, specifies to output match information (default = false).
bool legacy_version
The first implementation of this cost did not exactly match the cost of Hadsell et al 2006 – using (m...
double matching_distance_scale
Optionally, specifies the scale applied to the matching distance when calculating the loss (default =...
ContrastiveLossParameter()
Constructor for the parameter.
static ContrastiveLossParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
CENTROID_LEARNING centroid_learning
Optionally, specifies to use centroid learning as soon as the centroids (from the DecodeLayer) are re...
double margin
Margin for dissimilar pair.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
DISTANCE_CALCULATION distance_calculation
Optionally, specifies the distance calculation to use when calculating the distance between encoding ...
DISTANCE_CALCULATION
Defines the distance calculation to use.
CENTROID_LEARNING
Defines the type of centroid learning to use.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
@ ALL
Applies to all phases.
@ NONE
No training category specified.
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-...