Esempio n. 1
0
        /** @copydoc LayerParameterBase::Clone */
        public override LayerParameterBase Clone()
        {
            ContrastiveLossParameter p = new ContrastiveLossParameter();

            p.Copy(this);
            return(p);
        }
Esempio n. 2
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            ContrastiveLossParameter p = (ContrastiveLossParameter)src;

            m_dfMargin       = p.m_dfMargin;
            m_bLegacyVersion = p.m_bLegacyVersion;
        }
Esempio n. 3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            ContrastiveLossParameter p = (ContrastiveLossParameter)src;

            m_dfMargin            = p.m_dfMargin;
            m_bLegacyVersion      = p.m_bLegacyVersion;
            m_bOutputMatches      = p.m_bOutputMatches;
            m_centroidLearning    = p.m_centroidLearning;
            m_distanceCalc        = p.m_distanceCalc;
            m_dfMatchingDistScale = p.m_dfMatchingDistScale;
        }
Esempio n. 4
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto proto             = RawProto.Parse(br.ReadString());
            ContrastiveLossParameter p = FromProto(proto);

            if (!bNewInstance)
            {
                Copy(p);
            }

            return(p);
        }
Esempio n. 5
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static ContrastiveLossParameter FromProto(RawProto rp)
        {
            string strVal;
            ContrastiveLossParameter p = new ContrastiveLossParameter();

            if ((strVal = rp.FindValue("margin")) != null)
            {
                p.margin = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("legacy_version")) != null)
            {
                p.legacy_version = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("output_matches")) != null)
            {
                p.output_matches = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("centroid_learning")) != null)
            {
                if (strVal == CENTROID_LEARNING.ALL.ToString())
                {
                    p.centroid_learning = CENTROID_LEARNING.ALL;
                }
                else if (strVal == CENTROID_LEARNING.MATCHING.ToString())
                {
                    p.centroid_learning = CENTROID_LEARNING.MATCHING;
                }
                else if (strVal == CENTROID_LEARNING.NONMATCHING.ToString())
                {
                    p.centroid_learning = CENTROID_LEARNING.NONMATCHING;
                }
            }

            if ((strVal = rp.FindValue("distance_calculation")) != null)
            {
                if (strVal == DISTANCE_CALCULATION.MANHATTAN.ToString())
                {
                    p.distance_calculation = DISTANCE_CALCULATION.MANHATTAN;
                }
            }

            if ((strVal = rp.FindValue("matching_distance_scale")) != null)
            {
                p.matching_distance_scale = double.Parse(strVal);
            }

            return(p);
        }
Esempio n. 6
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static ContrastiveLossParameter FromProto(RawProto rp)
        {
            string strVal;
            ContrastiveLossParameter p = new ContrastiveLossParameter();

            if ((strVal = rp.FindValue("margin")) != null)
            {
                p.margin = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("legacy_version")) != null)
            {
                p.legacy_version = bool.Parse(strVal);
            }

            return(p);
        }