Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new copy of this instance of the parameter.
        /// </summary>
        /// <returns>A new instance of this parameter is returned.</returns>
        public override LayerParameterBase Clone()
        {
            ConstantParameter p = new ConstantParameter();

            p.Copy(this);
            return(p);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Copy on parameter to another.
        /// </summary>
        /// <param name="src">Specifies the parameter to copy.</param>
        public override void Copy(LayerParameterBase src)
        {
            ConstantParameter p = (ConstantParameter)src;

            m_outputShape       = p.output_shape.Clone();
            m_rgF               = new List <float>(p.m_rgF);
            m_strBinaryDataFile = p.binary_data_file;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the parameter from a binary reader.
        /// </summary>
        /// <param name="br">Specifies the binary reader.</param>
        /// <param name="bNewInstance">When <i>true</i> a new instance is created (the default), otherwise the existing instance is loaded from the binary reader.</param>
        /// <returns>Returns an instance of the parameter.</returns>
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto          proto = RawProto.Parse(br.ReadString());
            ConstantParameter p     = FromProto(proto);

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

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

            RawProto shape = rp.FindChild("output_shape");

            if (shape != null)
            {
                p.m_outputShape = BlobShape.FromProto(shape);
            }

            p.m_rgF = rp.FindArray <float>("valuef");

            strVal = rp.FindValue("binary_data_file");
            if (strVal != null)
            {
                p.m_strBinaryDataFile = replace(strVal, '~', ' ');
            }

            return(p);
        }