2using System.Collections.Generic;
14 [TypeConverter(typeof(ExpandableObjectConverter))]
28 [Description(
"Specifies the first axis to gather: all preceding axes are retained in the output.")]
31 get {
return m_nAxis; }
32 set { m_nAxis = value; }
36 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
71 rgChildren.
Add(
"axis",
axis.ToString());
73 return new RawProto(strName,
"", rgChildren);
86 if ((strVal = rp.
FindValue(
"axis")) !=
null)
87 p.
axis =
int.Parse(strVal);
105 public static List<int>
Reshape(
int nAxis, List<int> rgBtmShape, List<int> rgIdxShape,
float[] rgIdxF, out
int nDim, out
int nDimAtAxis, out
int nM, out
int nN, out
string strErr)
109 nDimAtAxis = rgBtmShape[nAxis];
117 if (nN != rgIdxF.Length)
119 strErr =
"N should equal the number of indices.";
123 for (
int i = 0; i < nN; i++)
125 int nIdx = (int)rgIdxF[i];
126 if (nIdx < -nDimAtAxis || nIdx > nDimAtAxis)
128 strErr =
"The index at idx=" + i.ToString() +
" is out of range! Must be within range [-" + nDimAtAxis.ToString() +
"," + nDimAtAxis.ToString() +
"]";
134 List<int> rgTopShape =
new List<int>(rgIdxShape);
135 int nLen = rgTopShape.Count;
137 while (rgTopShape.Count > 0 && rgTopShape[rgTopShape.Count - 1] == 1)
139 rgTopShape.RemoveAt(rgTopShape.Count - 1);
143 rgTopShape.Add(nDim);
145 rgTopShape.Insert(0, nM);
147 for (
int i = rgTopShape.Count; i < nLen; 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.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the GatherLayer.
int axis
Specifies the first axis to gather: all preceding axes are retained in the output....
override void Copy(LayerParameterBase src)
Copy on parameter to another.
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.
static List< int > Reshape(int nAxis, List< int > rgBtmShape, List< int > rgIdxShape, float[] rgIdxF, out int nDim, out int nDimAtAxis, out int nM, out int nN, out string strErr)
Calculate the reshape array given the parameters.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
static GatherParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
GatherParameter()
Constructor for the parameter.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.param.beta parameters are used by the MyCaffe.layer.beta layers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...