MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
PermuteParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.ssd
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 List<int> m_rgOrder = new List<int>();
22
27 {
28 }
29
38 [Description("Specifies the new orders of the axes of data. Should be within the same range as the input data starting with 0 and no repeated orders.")]
39 public List<int> order
40 {
41 get { return m_rgOrder; }
42 set { m_rgOrder = value; }
43 }
44
51 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
52 {
53 RawProto proto = RawProto.Parse(br.ReadString());
54 PermuteParameter p = FromProto(proto);
55
56 if (!bNewInstance)
57 Copy(p);
58
59 return p;
60 }
61
66 public override void Copy(LayerParameterBase src)
67 {
69 m_rgOrder = Utility.Clone<int>(p.order);
70 }
71
76 public override LayerParameterBase Clone()
77 {
79 p.Copy(this);
80 return p;
81 }
82
88 public override RawProto ToProto(string strName)
89 {
90 RawProtoCollection rgChildren = new RawProtoCollection();
91
92 foreach (int nOrder in m_rgOrder)
93 {
94 rgChildren.Add("order", nOrder.ToString());
95 }
96
97 return new RawProto(strName, "", rgChildren);
98 }
99
106 {
108
109 RawProtoCollection rgChildren = rp.FindChildren("order");
110 foreach (RawProto rp1 in rgChildren)
111 {
112 p.order.Add(int.Parse(rp1.Value));
113 }
114
115 return p;
116 }
117
125 public static List<int> Reshape(List<int> rgOrder, List<int> rgShape, int nNumAxes)
126 {
127 List<int> rgTopShape = new List<int>();
128
129 for (int i = 0; i < nNumAxes; i++)
130 {
131 int nOrder = rgOrder[i];
132 int nShape = rgShape[nOrder];
133 rgTopShape.Add(nShape);
134 }
135
136 return rgTopShape;
137 }
138 }
139}
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
string Value
Get/set the value of the node.
Definition: RawProto.cs:79
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
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 PermuteLayer.
static PermuteParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
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 List< int > Reshape(List< int > rgOrder, List< int > rgShape, int nNumAxes)
Calculates the top shape by running the Reshape calculation.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
List< int > order
Specifies the new orders of the axes of data.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.ssd namespace contains all SSD related parameter objects that correspond to the nat...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12