MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SliceParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7using MyCaffe.common;
8
9namespace MyCaffe.param
10{
14 [Serializable]
15 [TypeConverter(typeof(ExpandableObjectConverter))]
17 {
18 int m_nAxis = 1;
19 List<uint> m_rgSlicePoint = new List<uint>();
20 uint m_nSliceDim = 0;
21
24 {
25 }
26
32 [Description("Specifies the axis along which to slice - may be negative to index from the end (e.g., -1 for the last axis).")]
33 public int axis
34 {
35 get { return m_nAxis; }
36 set { m_nAxis = value; }
37 }
38
42 [Description("Specifies the optional slice points which indicate the indexes in the selected dimensions (the number of indices must be equal to the number of top blobs minus one).")]
43 public List<uint> slice_point
44 {
45 get { return m_rgSlicePoint; }
46 set { m_rgSlicePoint = value; }
47 }
48
52 [Description("DEPRECIATED - use 'axis' instead.")]
53 [Browsable(false)]
54 public uint slice_dim
55 {
56 get { return m_nSliceDim; }
57 set { m_nSliceDim = value; }
58 }
59
61 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
62 {
63 RawProto proto = RawProto.Parse(br.ReadString());
64 SliceParameter p = FromProto(proto);
65
66 if (!bNewInstance)
67 Copy(p);
68
69 return p;
70 }
71
73 public override void Copy(LayerParameterBase src)
74 {
76
77 m_nAxis = p.m_nAxis;
78 m_rgSlicePoint = Utility.Clone<uint>(p.m_rgSlicePoint);
79 m_nSliceDim = p.m_nSliceDim;
80 }
81
83 public override LayerParameterBase Clone()
84 {
86 p.Copy(this);
87 return p;
88 }
89
95 public override RawProto ToProto(string strName)
96 {
97 RawProtoCollection rgChildren = new RawProtoCollection();
98
99 rgChildren.Add("axis", axis.ToString());
100 rgChildren.Add<uint>("slice_point", slice_point);
101
102 if (slice_dim != 0)
103 rgChildren.Add("slice_dim", slice_dim.ToString());
104
105 return new RawProto(strName, "", rgChildren);
106 }
107
114 {
115 string strVal;
117
118 if ((strVal = rp.FindValue("axis")) != null)
119 p.axis = int.Parse(strVal);
120
121 p.slice_point = rp.FindArray<uint>("slice_point");
122
123 if ((strVal = rp.FindValue("slice_dim")) != null)
124 p.slice_dim = uint.Parse(strVal);
125
126 return p;
127 }
128 }
129}
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
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the SliceLayer.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
static SliceParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
SliceParameter()
Constructor for the parameter.
uint slice_dim
DEPRECIATED: alias for 'axis' – does not support negative indexing.
List< uint > slice_point
Specifies optional slice points which indicate the indexes in the selected dimensions (the number of ...
int axis
Specifies the axis along wich to slice – may be negative to index from the end (e....
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