/// <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 AttentionParameter FromProto(RawProto rp) { string strVal; AttentionParameter p = new AttentionParameter(); if ((strVal = rp.FindValue("axis")) != null) { p.axis = int.Parse(strVal); } if ((strVal = rp.FindValue("dim")) != null) { p.dim = uint.Parse(strVal); } RawProto rpWeightFiller = rp.FindChild("weight_filler"); if (rpWeightFiller != null) { p.weight_filler = FillerParameter.FromProto(rpWeightFiller); } RawProto rpBiasFiller = rp.FindChild("bias_filler"); if (rpBiasFiller != null) { p.bias_filler = FillerParameter.FromProto(rpBiasFiller); } return(p); }
/** @copydoc LayerParameterBase::Clone */ public override LayerParameterBase Clone() { AttentionParameter p = new AttentionParameter(); p.Copy(this); return(p); }
/** @copydoc LayerParameterBase::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); AttentionParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { AttentionParameter p = (AttentionParameter)src; m_nDim = p.dim; m_nAxis = p.m_nAxis; if (p.m_fillerParam_bias != null) { m_fillerParam_bias = p.m_fillerParam_bias.Clone(); } if (p.m_fillerParam_weights != null) { m_fillerParam_weights = p.m_fillerParam_weights.Clone(); } }