/** @copydoc LayerParameterBase::Clone */ public override LayerParameterBase Clone() { ReductionParameter p = new ReductionParameter(); p.Copy(this); return(p); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { ReductionParameter p = (ReductionParameter)src; m_operation = p.m_operation; m_nAxis = p.m_nAxis; m_dfCoeff = p.m_dfCoeff; }
/** @copydoc LayerParameterBase::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); ReductionParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }
/// <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 ReductionParameter FromProto(RawProto rp) { string strVal; ReductionParameter p = new ReductionParameter(); if ((strVal = rp.FindValue("operation")) != null) { switch (strVal) { case "ASUM": p.operation = ReductionOp.ASUM; break; case "MEAN": p.operation = ReductionOp.MEAN; break; case "SUM": p.operation = ReductionOp.SUM; break; case "SUMSQ": p.operation = ReductionOp.SUMSQ; break; case "MIN": p.operation = ReductionOp.MIN; break; case "MAX": p.operation = ReductionOp.MAX; break; default: throw new Exception("Uknown 'operation' value: " + strVal); } } if ((strVal = rp.FindValue("axis")) != null) { p.axis = int.Parse(strVal); } if ((strVal = rp.FindValue("coeff")) != null) { p.coeff = ParseDouble(strVal); } return(p); }