2using System.Collections.Generic;
18 [TypeConverter(typeof(ExpandableObjectConverter))]
33 [Description(
"Specifies the first axis to flatten: all preceding axes are retained in the output.")]
36 get {
return m_nAxis; }
37 set { m_nAxis = value; }
44 [Description(
"Specifies the last axis to flatten: all following axes are retained in the output.")]
47 get {
return m_nEndAxis; }
48 set { m_nEndAxis = value; }
52 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
68 m_nEndAxis = p.m_nEndAxis;
88 rgChildren.
Add(
"axis",
axis.ToString());
91 return new RawProto(strName,
"", rgChildren);
104 if ((strVal = rp.
FindValue(
"axis")) !=
null)
105 p.
axis =
int.Parse(strVal);
107 if ((strVal = rp.
FindValue(
"end_axis")) !=
null)
122 public static List<int>
Reshape(
int nParamAxis,
int nParamEndAxis, List<int> rgShape,
int nStartAxis = -1,
int nEndAxis = -1)
130 List<int> rgTopShape =
new List<int>();
131 for (
int i = 0; i < nStartAxis; i++)
133 rgTopShape.Add(rgShape[i]);
136 int nFlattenDim =
Utility.
Count(rgShape, nStartAxis, nEndAxis + 1);
137 rgTopShape.Add(nFlattenDim);
139 for (
int i = nEndAxis + 1; i < rgShape.Count; i++)
141 rgTopShape.Add(rgShape[i]);
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.
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
The Utility class provides general utility funtions.
static int CanonicalAxisIndex(int nIdx, int nNumAxes)
Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e...
static int Count(List< int > rgShape, int nStartIdx=0, int nEndIdx=-1)
Return the count of items given the shape.
Specifies the parameters for the FlattenLayer.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static FlattenParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
static List< int > Reshape(int nParamAxis, int nParamEndAxis, List< int > rgShape, int nStartAxis=-1, int nEndAxis=-1)
Calculate the reshape array given the parameters.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
int axis
Specifies the first axis to flatten: all preceding axes are retained in the output....
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int end_axis
Specifies the last axis to flatten: all following axes are retained in the output....
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
FlattenParameter()
Constructor for the parameter.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
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-...