/** @copydoc LayerParameterBase::Load */ public override object Load(BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); AnnotatedDataParameter p = FromProto(proto); if (!bNewInstance) Copy(p); return p; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { AnnotatedDataParameter p = (AnnotatedDataParameter)src; p.m_type = m_type; p.m_strLabelFile = m_strLabelFile; p.m_rgBatchSampler = new List<BatchSampler>(); foreach (BatchSampler bs in m_rgBatchSampler) { m_rgBatchSampler.Add(bs.Clone()); } }
/// <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 AnnotatedDataParameter FromProto(RawProto rp) { AnnotatedDataParameter p = new AnnotatedDataParameter(); string strVal; if ((strVal = rp.FindValue("anno_type")) != null) p.m_type = (SimpleDatum.ANNOTATION_TYPE)int.Parse(strVal); if ((strVal = rp.FindValue("label_map_file")) != null) p.m_strLabelFile = strVal; RawProtoCollection col = rp.FindChildren("batch_sampler"); foreach (RawProto rp1 in col) { p.m_rgBatchSampler.Add(BatchSampler.FromProto(rp1)); } return p; }