Пример #1
0
        /** @copydoc KernelParameter::Clone */
        public override LayerParameterBase Clone()
        {
            PoolingParameter p = new PoolingParameter();

            p.Copy(this);
            return(p);
        }
Пример #2
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 new PoolingParameter FromProto(RawProto rp)
        {
            string           strVal;
            PoolingParameter p = new PoolingParameter();

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

            if ((strVal = rp.FindValue("pool")) != null)
            {
                switch (strVal)
                {
                case "MAX":
                    p.pool = PoolingMethod.MAX;
                    break;

                case "AVE":
                    p.pool = PoolingMethod.AVE;
                    break;

                case "STOCHASTIC":
                    p.pool = PoolingMethod.STOCHASTIC;
                    break;

                default:
                    throw new Exception("Unknown pooling 'method' value: " + strVal);
                }
            }

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

            return(p);
        }
Пример #3
0
        /** @copydoc KernelParameter::Copy */
        public override void Copy(LayerParameterBase src)
        {
            base.Copy(src);

            if (src is PoolingParameter)
            {
                PoolingParameter p = (PoolingParameter)src;
                m_pool           = p.m_pool;
                m_bGlobalPooling = p.m_bGlobalPooling;
            }
        }
Пример #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 new UnPoolingParameter FromProto(RawProto rp)
        {
            UnPoolingParameter p = new UnPoolingParameter();

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

            p.m_rgUnpool = rp.FindArray <uint>("unpool_size");
            p.m_nUnPoolH = (uint?)rp.FindValue("unpool_h", typeof(uint));
            p.m_nUnPoolW = (uint?)rp.FindValue("unpool_w", typeof(uint));

            return(p);
        }
Пример #5
0
        /** @copydoc KernelParameter::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto         proto = RawProto.Parse(br.ReadString());
            PoolingParameter p     = FromProto(proto);

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

            return(p);
        }