MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
InputParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
10namespace MyCaffe.param
11{
18 [Serializable]
19 [TypeConverter(typeof(ExpandableObjectConverter))]
21 {
22 List<BlobShape> m_rgShape = new List<BlobShape>();
23
26 {
27 }
28
34 [Description("Define N shapes to set a shape for each top; Define 1 shape to set the same shape for every top; Define no shapes to defer to manual reshaping.")]
35 public List<BlobShape> shape
36 {
37 get { return m_rgShape; }
38 set { m_rgShape = value; }
39 }
40
42 public override object Load(BinaryReader br, bool bNewInstance = true)
43 {
44 RawProto proto = RawProto.Parse(br.ReadString());
45 InputParameter p = FromProto(proto);
46
47 if (!bNewInstance)
48 Copy(p);
49
50 return p;
51 }
52
54 public override void Copy(LayerParameterBase src)
55 {
57
58 m_rgShape = new List<param.BlobShape>();
59
60 foreach (BlobShape b in p.shape)
61 {
62 m_rgShape.Add(b.Clone());
63 }
64 }
65
67 public override LayerParameterBase Clone()
68 {
69 InputParameter p = new param.InputParameter();
70 p.Copy(this);
71 return p;
72 }
73
79 public override RawProto ToProto(string strName)
80 {
81 RawProtoCollection rgChildren = new RawProtoCollection();
82
83 foreach (BlobShape b in m_rgShape)
84 {
85 rgChildren.Add(b.ToProto("shape"));
86 }
87
88 return new RawProto(strName, "", rgChildren);
89 }
90
97 {
99
100 RawProtoCollection col = rp.FindChildren("shape");
101 foreach (RawProto rp1 in col)
102 {
104 p.m_rgShape.Add(b);
105 }
106
107 return p;
108 }
109 }
110}
The RawProtoCollection class is a list of RawProto objects.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
RawProtoCollection FindChildren(params string[] rgstrName)
Searches for all children with a given name in this node's children.
Definition: RawProto.cs:263
Specifies the shape of a Blob.
Definition: BlobShape.cs:15
override RawProto ToProto(string strName)
Converts the BlobShape to a RawProto.
Definition: BlobShape.cs:153
BlobShape Clone()
Creates a copy of the BlobShape.
Definition: BlobShape.cs:102
static BlobShape FromProto(RawProto rp)
Parse a new BlobShape from a RawProto.
Definition: BlobShape.cs:167
Specifies the parameters for the InputLayer.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
static InputParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
InputParameter()
Constructor for the parameter.
override object Load(BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
List< BlobShape > shape
Define N shapes to set a shape for each top. Define 1 shape to set the same shape for every top....
override void Copy(LayerParameterBase src)
Copy on parameter to another.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12