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

            p.Copy(this);
            return(p);
        }
コード例 #2
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto       proto = RawProto.Parse(br.ReadString());
            EmbedParameter p     = FromProto(proto);

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

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

            m_nNumOutput = p.m_nNumOutput;
            m_nInputDim  = p.m_nInputDim;
            m_bBiasTerm  = p.m_bBiasTerm;

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

            if (p.m_fillerParam_weights != null)
            {
                m_fillerParam_weights = p.m_fillerParam_weights.Clone();
            }
        }
コード例 #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 EmbedParameter FromProto(RawProto rp)
        {
            string         strVal;
            EmbedParameter p = new EmbedParameter();

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

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

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

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            return(p);
        }