Example #1
0
        /** @copydoc LayerParameterBase::Clone */
        public override LayerParameterBase Clone()
        {
            ScalarParameter p = new ScalarParameter();

            p.Copy(this);
            return(p);
        }
Example #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 ScalarParameter FromProto(RawProto rp)
        {
            string          strVal;
            ScalarParameter p = new ScalarParameter();

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

            if ((strVal = rp.FindValue("operation")) != null)
            {
                if (strVal == ScalarOp.MUL.ToString())
                {
                    p.m_op = ScalarOp.MUL;
                }
                else if (strVal == ScalarOp.ADD.ToString())
                {
                    p.m_op = ScalarOp.ADD;
                }
                else
                {
                    throw new Exception("Unknown scalar operation '" + strVal + "'");
                }
            }

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

            return(p);
        }
Example #3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            ScalarParameter p = (ScalarParameter)src;

            m_dfVal = p.m_dfVal;
            m_op    = p.m_op;
            m_bPassthroughGradient = p.m_bPassthroughGradient;
        }
Example #4
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto        proto = RawProto.Parse(br.ReadString());
            ScalarParameter p     = FromProto(proto);

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

            return(p);
        }