/** @copydoc EngineParameter::Clone */ public override LayerParameterBase Clone() { LRNParameter p = new LRNParameter(); p.Copy(this); return(p); }
/** @copydoc EngineParameter::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); LRNParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }
/** @copydoc EngineParameter::Copy */ public override void Copy(LayerParameterBase src) { base.Copy(src); if (src is LRNParameter) { LRNParameter p = (LRNParameter)src; m_nLocalSize = p.m_nLocalSize; m_dfAlpha = p.m_dfAlpha; m_dfBeta = p.m_dfBeta; m_normRegion = p.m_normRegion; m_dfK = p.m_dfK; } }
/// <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 new LRNParameter FromProto(RawProto rp) { string strVal; LRNParameter p = new LRNParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("local_size")) != null) { p.local_size = uint.Parse(strVal); } if ((strVal = rp.FindValue("alpha")) != null) { p.alpha = ParseDouble(strVal); } if ((strVal = rp.FindValue("beta")) != null) { p.beta = ParseDouble(strVal); } if ((strVal = rp.FindValue("norm_region")) != null) { switch (strVal) { case "ACROSS_CHANNELS": p.norm_region = NormRegion.ACROSS_CHANNELS; break; case "WITHIN_CHANNEL": p.norm_region = NormRegion.WITHIN_CHANNEL; break; default: throw new Exception("Unknown 'norm_region' value: " + strVal); } } if ((strVal = rp.FindValue("k")) != null) { p.k = ParseDouble(strVal); } return(p); }