/** @copydoc LayerParameterBase::Clone */
        public override LayerParameterBase Clone()
        {
            BatchNormParameter p = new BatchNormParameter();

            p.Copy(this);
            return(p);
        }
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            base.Copy(src);

            if (src is BatchNormParameter)
            {
                BatchNormParameter p = (BatchNormParameter)src;
                m_bUseGlobalStats         = p.m_bUseGlobalStats;
                m_dfEps                   = p.m_dfEps;
                m_dfMovingAverageFraction = p.m_dfMovingAverageFraction;
                m_bScaleBias              = p.m_bScaleBias;
                m_biasFiller              = p.m_biasFiller;

                if (p.m_scaleFiller != null)
                {
                    m_scaleFiller = p.m_scaleFiller.Clone();
                }
                else
                {
                    m_scaleFiller = null;
                }

                if (p.m_biasFiller != null)
                {
                    m_biasFiller = p.m_biasFiller.Clone();
                }
                else
                {
                    m_biasFiller = null;
                }
            }
        }
Exemple #3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            BatchNormParameter p = (BatchNormParameter)src;

            p.m_bUseGlobalStats         = m_bUseGlobalStats;
            p.m_dfEps                   = m_dfEps;
            p.m_dfMovingAverageFraction = m_dfMovingAverageFraction;
        }
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto           proto = RawProto.Parse(br.ReadString());
            BatchNormParameter p     = FromProto(proto);

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

            return(p);
        }
        /// <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 new BatchNormParameter FromProto(RawProto rp)
        {
            string             strVal;
            BatchNormParameter p = new BatchNormParameter();

            ((EngineParameter)p).Copy(EngineParameter.FromProto(rp));

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

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

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

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

                RawProto rp1;

                if ((rp1 = rp.FindChild("scale_filler")) != null)
                {
                    p.scale_filler = FillerParameter.FromProto(rp1);
                }

                if ((rp1 = rp.FindChild("bias_filler")) != null)
                {
                    p.bias_filler = FillerParameter.FromProto(rp1);
                }
            }

            return(p);
        }
Exemple #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 BatchNormParameter FromProto(RawProto rp)
        {
            string             strVal;
            BatchNormParameter p = new BatchNormParameter();

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

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

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

            return(p);
        }