/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <param name="p">Optionally, specifies an instance to load. If <i>null</i>, a new instance is created and loaded.</param> /// <returns>A new instance of the parameter is returned.</returns> public static ModelDataParameter FromProto(RawProto rp, ModelDataParameter p = null) { string strVal; if (p == null) { p = new ModelDataParameter(); } p.source = rp.FindArray <string>("source"); if ((strVal = rp.FindValue("batch_size")) != null) { p.batch_size = uint.Parse(strVal); } if ((strVal = rp.FindValue("time_steps")) != null) { p.time_steps = uint.Parse(strVal); } if ((strVal = rp.FindValue("input_dim")) != null) { p.input_dim = uint.Parse(strVal); } if ((strVal = rp.FindValue("shuffle")) != null) { p.shuffle = bool.Parse(strVal); } return(p); }
/** @copydoc LayerParameterBase::Clone */ public override LayerParameterBase Clone() { ModelDataParameter p = new ModelDataParameter(); p.Copy(this); return(p); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { ModelDataParameter p = (ModelDataParameter)src; m_rgstrSource = Utility.Clone <string>(p.source); m_nBatchSize = p.m_nBatchSize; m_nTimeSteps = p.m_nTimeSteps; m_nInputDim = p.m_nInputDim; m_nSampleSize = p.m_nSampleSize; m_bShuffle = p.m_bShuffle; }
/** @copydoc LayerParameterBase::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); ModelDataParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }