/** @copydoc LayerParameterBase::Clone */ public override LayerParameterBase Clone() { EltwiseParameter p = new EltwiseParameter(); p.Copy(this); return(p); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { EltwiseParameter p = (EltwiseParameter)src; m_operation = p.m_operation; m_rgdfCoeff = Utility.Clone <double>(p.m_rgdfCoeff); m_bStableProdGrad = p.m_bStableProdGrad; m_bCoeffBlob = p.m_bCoeffBlob; }
/** @copydoc LayerParameterBase::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); EltwiseParameter 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 EltwiseParameter FromProto(RawProto rp) { string strVal; EltwiseParameter p = new EltwiseParameter(); if ((strVal = rp.FindValue("operation")) != null) { switch (strVal) { case "PROD": p.operation = EltwiseOp.PROD; break; case "SUM": p.operation = EltwiseOp.SUM; break; case "MAX": p.operation = EltwiseOp.MAX; break; case "MIN": p.operation = EltwiseOp.MIN; break; case "DIV": p.operation = EltwiseOp.DIV; break; case "SUB": p.operation = EltwiseOp.SUB; break; default: throw new Exception("Unknown 'operation' value: " + strVal); } } p.coeff = rp.FindArray <double>("coeff"); if ((strVal = rp.FindValue("stable_prod_grad")) != null) { p.stable_prod_grad = bool.Parse(strVal); } if ((strVal = rp.FindValue("coeff_blob")) != null) { p.coeff_blob = bool.Parse(strVal); } return(p); }