/// <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 Normalization2Parameter FromProto(RawProto rp) { string strVal; Normalization2Parameter p = new Normalization2Parameter(); if ((strVal = rp.FindValue("across_spatial")) != null) { p.across_spatial = bool.Parse(strVal); } if ((strVal = rp.FindValue("channel_shared")) != null) { p.channel_shared = bool.Parse(strVal); } if ((strVal = rp.FindValue("eps")) != null) { p.eps = ParseFloat(strVal); } RawProto rgScaleFiller = rp.FindChild("scale_filler"); if (rgScaleFiller != null) { p.scale_filler = FillerParameter.FromProto(rgScaleFiller); } return(p); }
/// <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() { Normalization2Parameter p = new Normalization2Parameter(); p.Copy(this); return(p); }
/// <summary> /// Copy on parameter to another. /// </summary> /// <param name="src">Specifies the parameter to copy.</param> public override void Copy(LayerParameterBase src) { Normalization2Parameter p = (Normalization2Parameter)src; m_bAcrossSpatial = p.m_bAcrossSpatial; m_bChannelShared = p.m_bChannelShared; m_fEps = p.m_fEps; m_scaleFiller = p.m_scaleFiller.Clone(); }
/// <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()); Normalization2Parameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }