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

            p.Copy(this);
            return(p);
        }
Exemplo n.º 2
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto            proto = RawProto.Parse(br.ReadString());
            BinaryHashParameter p     = FromProto(proto);

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

            return(p);
        }
Exemplo n.º 3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            BinaryHashParameter p = (BinaryHashParameter)src;

            m_nCacheDepth = p.m_nCacheDepth;
            m_dfBinaryThresholdForPooling = p.m_dfBinaryThresholdForPooling;
            m_nTopK                = p.m_nTopK;
            m_nPoolSize            = p.m_nPoolSize;
            m_bEnableDebug         = p.m_bEnableDebug;
            m_selMethod            = p.m_selMethod;
            m_nIterationEnable     = p.m_nIterationEnable;
            m_bEnableDuringTesting = p.m_bEnableDuringTesting;
            m_distPass1            = p.m_distPass1;
            m_distPass2            = p.m_distPass2;
            m_bEnableTripletLoss   = p.m_bEnableTripletLoss;
            m_dfAlpha              = p.m_dfAlpha;
        }
Exemplo n.º 4
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 BinaryHashParameter FromProto(RawProto rp)
        {
            string strVal;
            BinaryHashParameter p = new BinaryHashParameter();

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

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

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

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

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

            if ((strVal = rp.FindValue("selection_method")) != null)
            {
                if (strVal == SELECTION_METHOD.HIGHEST_VOTE.ToString())
                {
                    p.selection_method = SELECTION_METHOD.HIGHEST_VOTE;
                }
                else
                {
                    p.selection_method = SELECTION_METHOD.MINIMUM_DISTANCE;
                }
            }

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

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

            if ((strVal = rp.FindValue("dist_calc_pass1")) != null)
            {
                if (strVal == DISTANCE_TYPE.EUCLIDEAN.ToString())
                {
                    p.dist_calc_pass1 = DISTANCE_TYPE.EUCLIDEAN;
                }
                else
                {
                    p.dist_calc_pass1 = DISTANCE_TYPE.HAMMING;
                }
            }

            if ((strVal = rp.FindValue("dist_calc_pass2")) != null)
            {
                if (strVal == DISTANCE_TYPE.HAMMING.ToString())
                {
                    p.dist_calc_pass2 = DISTANCE_TYPE.HAMMING;
                }
                else
                {
                    p.dist_calc_pass2 = DISTANCE_TYPE.EUCLIDEAN;
                }
            }

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

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

            return(p);
        }