MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
CropParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7using MyCaffe.common;
8
9namespace MyCaffe.param
10{
22 [Serializable]
23 [TypeConverter(typeof(ExpandableObjectConverter))]
25 {
26 int m_nAxis = 2;
27 List<uint> m_rgOffset = new List<uint>();
28
31 {
32 }
33
42 [Description("The axis along which to crop - may be negative to index from the end (e.g., -1 for the last axis). Other axes must have the same dimension for all the bottom blobs. By default, the ConcatLayer concatenates blobs along the 'channel' axis 1.")]
43 public int axis
44 {
45 get { return m_nAxis; }
46 set { m_nAxis = value; }
47 }
48
57 [Description("")]
58 public List<uint> offset
59 {
60 get { return m_rgOffset; }
61 set { m_rgOffset = value; }
62 }
63
65 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
66 {
67 RawProto proto = RawProto.Parse(br.ReadString());
68 CropParameter p = FromProto(proto);
69
70 if (!bNewInstance)
71 Copy(p);
72
73 return p;
74 }
75
77 public override void Copy(LayerParameterBase src)
78 {
80 m_nAxis = p.m_nAxis;
81 m_rgOffset = Utility.Clone<uint>(p.m_rgOffset);
82 }
83
85 public override LayerParameterBase Clone()
86 {
88 p.Copy(this);
89 return p;
90 }
91
97 public override RawProto ToProto(string strName)
98 {
99 RawProtoCollection rgChildren = new RawProtoCollection();
100
101 if (axis != 1)
102 rgChildren.Add("axis", axis.ToString());
103
104 rgChildren.Add<uint>("offset", offset);
105
106 return new RawProto(strName, "", rgChildren);
107 }
108
115 {
116 string strVal;
118
119 if ((strVal = rp.FindValue("axis")) != null)
120 p.axis = int.Parse(strVal);
121
122 p.offset = rp.FindArray<uint>("offset");
123
124 return p;
125 }
126 }
127}
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
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
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The Utility class provides general utility funtions.
Definition: Utility.cs:35
Specifies the parameters for the MyCaffe.CropLayer.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static CropParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
List< uint > offset
Specifies the offset to set the shift for all/each dimension.
CropParameter()
Constructor for the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
int axis
The axis along which to crop – may be negative to index from the end (e.g., -1 for the last axis)....
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
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.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
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