Exemplo n.º 1
0
        /// <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 HDF5DataParameter FromProto(RawProto rp, HDF5DataParameter p = null)
        {
            string strVal;

            if (p == null)
                p = new HDF5DataParameter();

            if ((strVal = rp.FindValue("source")) != null)
                p.source = strVal.Trim('\"');

            if ((strVal = rp.FindValue("batch_size")) != null)
                p.batch_size = uint.Parse(strVal);

            if ((strVal = rp.FindValue("shuffle")) != null)
                p.shuffle = bool.Parse(strVal);

            p.m_rgExpectedTopShapes = new List<BlobShape>();
            RawProtoCollection colExpectedTopShapes = rp.FindChildren("expected_top_shape");
            foreach (RawProto rp1 in colExpectedTopShapes)
            {
                p.m_rgExpectedTopShapes.Add(BlobShape.FromProto(rp1));
            }

            return p;
        }
Exemplo n.º 2
0
        /** @copydoc LayerParameterBase::Load */
        public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
        {
            RawProto proto = RawProto.Parse(br.ReadString());
            HDF5DataParameter p = FromProto(proto);

            if (!bNewInstance)
                Copy(p);

            return p;
        }
Exemplo n.º 3
0
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            HDF5DataParameter p = (HDF5DataParameter)src;
            m_strSource = p.m_strSource;
            m_nBatchSize = p.m_nBatchSize;
            m_bShuffle = p.m_bShuffle;

            m_rgExpectedTopShapes = new List<BlobShape>();
            foreach (BlobShape shape in p.m_rgExpectedTopShapes)
            {
                m_rgExpectedTopShapes.Add(shape.Clone());
            }
        }
Exemplo n.º 4
0
 /** @copydoc LayerParameterBase::Clone */
 public override LayerParameterBase Clone()
 {
     HDF5DataParameter p = new HDF5DataParameter();
     p.Copy(this);
     return p;
 }