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

            p.Copy(this);
            return(p);
        }
Пример #2
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            LossParameter p = (LossParameter)src;

            m_nIgnoreLabel  = p.m_nIgnoreLabel;
            m_normalization = p.m_normalization;
            m_bNormalize    = p.m_bNormalize;
        }
Пример #3
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto      proto = RawProto.Parse(br.ReadString());
            LossParameter p     = FromProto(proto);

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

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

            p.ignore_label = (int?)rp.FindValue("ignore_label", typeof(int));

            if ((strVal = rp.FindValue("normalization")) != null)
            {
                switch (strVal)
                {
                case "FULL":
                    p.normalization = NormalizationMode.FULL;
                    break;

                case "VALID":
                    p.normalization = NormalizationMode.VALID;
                    break;

                case "BATCH_SIZE":
                    p.normalization = NormalizationMode.BATCH_SIZE;
                    break;

                case "NONE":
                    p.normalization = NormalizationMode.NONE;
                    break;

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

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

            return(p);
        }