/// <summary> /// Loads a BlobProto from a binary reader. /// </summary> /// <param name="br">Specifies the binary reader.</param> /// <param name="bNewInstance">When <i>true</i> a new instance is created, otherwise the data is read into the existing BlobProto.</param> /// <returns>The instance of the BlobProto is returned.</returns> public object Load(BinaryReader br, bool bNewInstance) { BlobProto p = this; if (bNewInstance) { p = new BlobProto(); } if (br.ReadBoolean()) { m_rgShape = BlobShape.Load(br); } m_rgdfData = Utility.Load <double>(br); m_rgdfDiff = Utility.Load <double>(br); m_rgfData = Utility.Load <float>(br); m_rgfDiff = Utility.Load <float>(br); if (br.ReadBoolean()) { m_nNum = br.ReadInt32(); } if (br.ReadBoolean()) { m_nChannels = br.ReadInt32(); } if (br.ReadBoolean()) { m_nHeight = br.ReadInt32(); } if (br.ReadBoolean()) { m_nWidth = br.ReadInt32(); } return(p); }
/// <summary> /// Parses a new BlobProto from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the BlobProto is returned.</returns> public static BlobProto FromProto(RawProto rp) { BlobProto p = new BlobProto(); RawProto rpShape = rp.FindChild("shape"); if (rpShape != null) { p.shape = BlobShape.FromProto(rpShape); } p.num = (int?)rp.FindValue("num", typeof(int)); p.channels = (int?)rp.FindValue("channels", typeof(int)); p.height = (int?)rp.FindValue("height", typeof(int)); p.width = (int?)rp.FindValue("width", typeof(int)); p.double_data = rp.FindArray <double>("double_data"); p.double_diff = rp.FindArray <double>("double_diff"); p.data = rp.FindArray <float>("data"); p.diff = rp.FindArray <float>("diff"); return(p); }
/// <summary> /// Load a new BlobProto from a binary reader. /// </summary> /// <param name="br">Specifies the binary reader.</param> /// <returns>A new instance of the BlobProto is returned.</returns> public static BlobProto Load(BinaryReader br) { BlobProto b = new BlobProto(); return((BlobProto)b.Load(br, true)); }