コード例 #1
0
        /** @copydoc LayerParameterBase::Clone */
        public override LayerParameterBase Clone()
        {
            MemoryDataParameter p = new MemoryDataParameter();

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

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

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

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

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

            return(p);
        }
コード例 #3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            MemoryDataParameter p = (MemoryDataParameter)src;

            m_nBatchSize = p.m_nBatchSize;
            m_nChannels  = p.m_nChannels;
            m_nHeight    = p.m_nHeight;
            m_nWidth     = p.m_nWidth;
        }
コード例 #4
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto            proto = RawProto.Parse(br.ReadString());
            MemoryDataParameter p     = FromProto(proto);

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

            return(p);
        }
コード例 #5
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            MemoryDataParameter p = (MemoryDataParameter)src;

            m_nBatchSize     = p.m_nBatchSize;
            m_nDataChannels  = p.m_nDataChannels;
            m_nDataHeight    = p.m_nDataHeight;
            m_nDataWidth     = p.m_nDataWidth;
            m_nLabelChannels = p.m_nLabelChannels;
            m_nLabelHeight   = p.m_nLabelHeight;
            m_nLabelWidth    = p.m_nLabelWidth;
            m_labelType      = p.m_labelType;
            m_bPrimaryData   = p.m_bPrimaryData;
        }
コード例 #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 MemoryDataParameter FromProto(RawProto rp)
        {
            string strVal;
            MemoryDataParameter p = new MemoryDataParameter();

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

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

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

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

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

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

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

            if ((strVal = rp.FindValue("label_type")) != null)
            {
                switch (strVal)
                {
                case "NONE":
                    p.label_type = LABEL_TYPE.NONE;
                    break;

                case "SINGLE":
                    p.label_type = LABEL_TYPE.SINGLE;
                    break;

                case "MULTIPLE":
                    p.label_type = LABEL_TYPE.MULTIPLE;
                    break;

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

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

            if ((strVal = rp.FindValue("clip_length1")) != null)
            {
                int nVal = int.Parse(strVal);
                if (nVal < 0)
                {
                    nVal = 0;
                }

                p.clip_length1 = (uint)nVal;
            }

            if ((strVal = rp.FindValue("clip_length2")) != null)
            {
                int nVal = int.Parse(strVal);
                if (nVal < 0)
                {
                    nVal = 0;
                }

                p.clip_length2 = (uint)nVal;
            }

            return(p);
        }