2using System.Collections.Generic;
16 [TypeConverter(typeof(ExpandableObjectConverter))]
19 string m_strName =
"";
20 List<string> m_rgstrInput =
new List<string>();
21 List<BlobShape> m_rgInputShape =
new List<BlobShape>();
22 List<int> m_rgInputDim =
new List<int>();
23 bool m_bForceBackward =
false;
25 bool m_bDebugInfo =
false;
26 List<LayerParameter> m_rgLayers =
new List<LayerParameter>();
28 int m_nSolverCount = 1;
29 int m_nSolverRank = 0;
41 public void Save(BinaryWriter bw)
47 bw.Write(m_bForceBackward);
49 bw.Write(m_bDebugInfo);
62 p.m_strName = br.ReadString();
63 p.m_rgstrInput =
Utility.Load<
string>(br);
65 p.m_rgInputDim =
Utility.Load<
int>(br);
66 p.m_bForceBackward = br.ReadBoolean();
68 p.m_bDebugInfo = br.ReadBoolean();
78 [Description(
"Specifies the ID of the project that created this net param (if any).")]
81 get {
return m_nProjectID; }
82 set { m_nProjectID = value; }
88 [Description(
"The name of the network.")]
91 get {
return m_strName; }
92 set { m_strName = value; }
101 get {
return m_rgstrInput; }
102 set { m_rgstrInput = value; }
111 get {
return m_rgInputShape; }
112 set { m_rgInputShape = value; }
124 get {
return m_rgInputDim; }
125 set { m_rgInputDim = value; }
133 [Description(
"Specifies whether or not the network will force every layer to carry out the backward operation.")]
136 get {
return m_bForceBackward; }
137 set { m_bForceBackward = value; }
148 get {
return m_state; }
149 set { m_state = value; }
156 [Description(
"Specifies whether or not to output debugging information to the output window.")]
159 get {
return m_bDebugInfo; }
160 set { m_bDebugInfo = value; }
170 get {
return m_rgLayers; }
171 set { m_rgLayers = value; }
180 get {
return m_nSolverCount; }
181 set { m_nSolverCount = value; }
190 get {
return m_nSolverRank; }
191 set { m_nSolverRank = value; }
197 return ToProto(strName,
false);
211 rgChildren.
Add<
string>(
"input",
input);
215 rgChildren.Add(bs.
ToProto(
"input_shape"));
218 rgChildren.Add<
int>(
"input_dim",
input_dim);
227 rgChildren.Add(
"debug_info",
debug_info.ToString());
231 rgChildren.Add(lp.
ToProto(
"layer"));
234 return new RawProto(strName,
"", rgChildren);
247 if ((strVal = rp.
FindValue(
"name")) !=
null)
250 p.
input = rp.FindArray<
string>(
"input");
258 p.input_dim = rp.FindArray<
int>(
"input_dim");
260 if ((strVal = rp.FindValue(
"force_backward")) !=
null)
261 p.force_backward =
bool.Parse(strVal);
267 if ((strVal = rp.FindValue(
"debug_info")) !=
null)
268 p.debug_info =
bool.Parse(strVal);
270 rgp = rp.FindChildren(
"layer",
"layers");
286 List<string> rgstrInput = rp.FindArray<
string>(
"input");
287 List<BlobShape> rgShape =
new List<BlobShape>();
295 if (rgstrInput.Count != rgShape.Count)
296 throw new Exception(
"The input array and shape array must have the same count!");
298 Dictionary<string, BlobShape> rgInput =
new Dictionary<string, BlobShape>();
299 for (
int i = 0; i < rgstrInput.Count; i++)
301 rgInput.Add(rgstrInput[i], rgShape[i]);
314 public NetParameter Clone(
bool bCloneLayers =
true,
int? nSolverCount =
null,
int? nSolverRank =
null)
318 p.m_nProjectID = m_nProjectID;
319 p.m_strName = m_strName;
320 p.m_rgstrInput =
Utility.Clone<
string>(m_rgstrInput);
322 p.m_rgInputDim =
Utility.Clone<
int>(m_rgInputDim);
323 p.m_bForceBackward = m_bForceBackward;
324 p.m_state = (m_state !=
null) ? m_state.
Clone() :
null;
325 p.m_bDebugInfo = m_bDebugInfo;
330 if (nSolverCount ==
null)
331 nSolverCount = m_nSolverCount;
333 if (nSolverRank ==
null)
334 nSolverRank = m_nSolverRank;
336 p.m_nSolverCount = nSolverCount.Value;
337 p.m_nSolverRank = nSolverRank.Value;
348 string str = m_strName +
" -> layers(" + m_rgLayers.Count.ToString() +
") {";
356 str = str.TrimEnd(
' ',
',');
389 for (
int i = 0; i < m_rgLayers.Count; i++)
391 if (m_rgLayers[i].
name == strName)
407 layer.pooling_param.reshape_algorithm = alg;
The BaseParameter class is the base class for all other parameter classes.
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.
TYPE
Defines the type of a RawProto node.
RawProto FindChild(string strName)
Searches for a given node.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
RawProtoCollection FindChildren(params string[] rgstrName)
Searches for all children with a given name in this node's children.
The Utility class provides general utility funtions.
static void Save(BinaryWriter bw, List< double > rg)
Save a list of double to a binary writer.
Specifies the shape of a Blob.
override RawProto ToProto(string strName)
Converts the BlobShape to a RawProto.
static BlobShape FromProto(RawProto rp)
Parse a new BlobShape from a RawProto.
Specifies the base parameter for all layers.
string name
Specifies the name of this LayerParameter.
LayerType type
Specifies the type of this LayerParameter.
bool MeetsPhase(Phase phase)
Determines whether or not this LayerParameter meets a given Phase.
static LayerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
LayerType
Specifies the layer type.
override RawProto ToProto(string strName)
Constructor for the parameter.
Specifies the parameters use to create a Net
static NetParameter FromProto(RawProto rp)
Parse a RawProto into a new instance of the parameter.
NetState state
The current 'state' of the network, including the phase, level and stage. Some layers may be included...
bool debug_info
Print debugging information about results while running Net::Forward, Net::Backward and Net::Update.
List< string > input
The input blobs to the network.
bool force_backward
Whether the network will force every layer to carry out backward operation. If set False,...
int ProjectID
Specifies the ID of the project that created this net param (if any).
int FindLayerIndex(string strName)
Locates the index of a layer based on a given layer name.
string DebugString()
Returns a debug string for the network.
List< int > input_dim
DEPRECIATED - 4D input dimensions - use 'input_shape' instead. If specified, for each input blob ther...
string name
The name of the network.
override RawProto ToProto(string strName)
Constructor for the parameter.
List< LayerParameter > layer
The layers that make up the net. Each of their configurations, including connectivity and behavior,...
LayerParameter FindLayer(LayerParameter.LayerType type, Phase phase=Phase.NONE)
Locates a layer based on a layer type and phase.
int solver_rank
Specifies the rank of the solver using this network.
void SetPoolingReshapeAlgorithm(PoolingParameter.PoolingReshapeAlgorithm alg)
Sets all pooling layers to use the specified reshape algorithm.
NetParameter()
Constructor for the parameter.
void Save(BinaryWriter bw)
Save the parameter to a binary writer.
RawProto ToProto(string strName, bool bIncludeState)
Save the parameter settings to a RawProto.
int solver_count
Specifies the number of solvers used in a multi-gpu training session.
static Dictionary< string, BlobShape > InputFromProto(RawProto rp)
Collect the inputs from the RawProto.
NetParameter Clone(bool bCloneLayers=true, int? nSolverCount=null, int? nSolverRank=null)
Creates a new copy of this instance of the parameter.
List< BlobShape > input_shape
The shape of the input blobs.
static NetParameter Load(BinaryReader br)
Load a new instance of the parameter from a binary reader.
Specifies the NetState which includes the phase, level and stage for which a given Net is to run unde...
static NetState FromProto(RawProto rp)
Parses a RawProto representing a NetState into a NetState instance.
override RawProto ToProto(string strName)
Converts this NetState to a RawProto.
NetState Clone()
Creates a new copy of this NetState instance.
static NetState Load(BinaryReader br)
Loads a new NetState instance from a binary reader.
void Save(BinaryWriter bw)
Saves the NetState to a binary writer.
Specifies the parameters for the PoolingLayer.
PoolingReshapeAlgorithm
Defines the pooling reshape algorithm to use.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Phase
Defines the Phase under which to run a Net.
The MyCaffe.common namespace contains common MyCaffe classes.
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-...