2using System.Collections.Generic;
5using System.Threading.Tasks;
81 : base(cuda, log, p, evtCancel)
104 rgNames.Add(
"h_" +
m_nT.ToString());
118 for (
int i = 0; i < nNumBlobs; i++)
146 m_log.
CHECK_GT(nNumOutput, 0,
"num_output must be positive.");
173 List<BlobShape> rgInputShapes =
new List<BlobShape>();
175 m_log.
CHECK_EQ(2, rgInputShapes.Count,
"There should be 2 input shapes.");
181 input_layer_param.
top.Add(
"c_0");
183 input_layer_param.
top.Add(
"h_0");
185 net_param.
layer.Add(input_layer_param);
188 cont_slice_param.
name =
"cont_slice";
189 cont_slice_param.
bottom.Add(
"cont");
191 net_param.
layer.Add(cont_slice_param);
197 x_transform_param.
name =
"x_transform";
200 x_transform_param.
bottom.Add(
"x");
201 x_transform_param.
top.Add(
"W_xc_x");
203 net_param.
layer.Add(x_transform_param);
212 x_static_transform_param.
name =
"W_xc_x_static";
214 x_static_transform_param.
bottom.Add(
"x_static");
215 x_static_transform_param.
top.Add(
"W_xc_x_static_preshape");
217 net_param.
layer.Add(x_static_transform_param);
221 new_shape.
dim.Add(1);
222 new_shape.
dim.Add(-1);
224 reshape_param.
name =
"W_xc_x_static_reshape";
225 reshape_param.
bottom.Add(
"W_xc_x_static_preshape");
226 reshape_param.
top.Add(
"W_xc_x_static");
227 net_param.
layer.Add(reshape_param);
231 x_slice_param.
name =
"W_xc_x_slice";
232 x_slice_param.
bottom.Add(
"W_xc_x");
233 net_param.
layer.Add(x_slice_param);
236 output_concat_layer.
name =
"h_concat";
237 output_concat_layer.
top.Add(
"h");
240 for (
int t = 1; t <=
m_nT; t++)
242 string tm1s = (t - 1).ToString();
243 string ts = t.ToString();
245 cont_slice_param.
top.Add(
"cont_" + ts);
246 x_slice_param.
top.Add(
"W_xc_x_" + ts);
259 cont_h_param.
name =
"h_conted_" + tm1s;
260 cont_h_param.
bottom.Add(
"h_" + tm1s);
261 cont_h_param.
bottom.Add(
"cont_" + ts);
262 cont_h_param.
top.Add(
"h_conted_" + tm1s);
263 net_param.
layer.Add(cont_h_param);
270 w_param.
name =
"transform_" + ts;
272 w_param.
bottom.Add(
"h_conted_" + tm1s);
273 w_param.
top.Add(
"W_hc_h_" + tm1s);
275 net_param.
layer.Add(w_param);
283 input_sum_layer.
name =
"gate_input_" + ts;
284 input_sum_layer.
bottom.Add(
"W_hc_h_" + tm1s);
285 input_sum_layer.
bottom.Add(
"W_xc_x_" + ts);
287 input_sum_layer.
bottom.Add(
"W_xc_x_static");
288 input_sum_layer.
top.Add(
"gate_input_" + ts);
289 net_param.
layer.Add(input_sum_layer);
307 lstm_unit_param.
bottom.Add(
"c_" + tm1s);
308 lstm_unit_param.
bottom.Add(
"gate_input_" + ts);
309 lstm_unit_param.
bottom.Add(
"cont_" + ts);
310 lstm_unit_param.
top.Add(
"c_" + ts);
311 lstm_unit_param.
top.Add(
"h_" + ts);
312 lstm_unit_param.
name =
"unit_" + ts;
313 net_param.
layer.Add(lstm_unit_param);
316 output_concat_layer.
bottom.Add(
"h_" + ts);
321 c_T_copy_param.
bottom.Add(
"c_" +
m_nT.ToString());
322 c_T_copy_param.
top.Add(
"c_T");
323 net_param.
layer.Add(c_T_copy_param);
326 net_param.
layer.Add(output_concat_layer.
Clone(
false));
The CancelEvent provides an extension to the manual cancel event that allows for overriding the manua...
The Log class provides general output in text form.
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
void CHECK_GT(double df1, double df2, string str)
Test whether one number is greater than another.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
The LSTMLayer processes sequential inputs using a 'Long Short-Term Memory' (LSTM) [1] style recurrent...
LSTMLayer(CudaDnn< T > cuda, Log log, LayerParameter p, CancelEvent evtCancel)
The LSTMLayer constructor.
override void FillUnrolledNet(NetParameter net_param)
Fills the NetParameter with the LSTM network architecture.
override void RecurrentOutputBlobNames(List< string > rgNames)
Fills the rgNames array with names of the Tth timestep recurrent output Blobs.
override void RecurrentInputBlobNames(List< string > rgNames)
Fills the rgNames array with the names of the 0th timestep recurrent input Blobs.
override void OutputBlobNames(List< string > rgNames)
Fills the rgNames array with the names of the output Blobs, concatenated across all timesteps.
override void RecurrentInputShapes(List< BlobShape > rgShapes)
Fill the rgShapes array with the shapes of the recurrent input Blobs.
Log m_log
Specifies the Log for output.
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
LayerParameter.LayerType m_type
Specifies the Layer type.
The RecurrentLayer is an abstract class for implementing recurrent behavior inside of an unrolled new...
int m_nN
The number of independent streams to process simultaneously.
int m_nT
The number of timesteps in the layer's input, and the number of timesteps over which to backpropagate...
bool m_bStaticInput
Whether the layer has a 'static' input copies across all timesteps.
int axis
The first axis of bottom[0] (the first input Blob) along which to apply bottom[1] (the second input B...
Specifies the shape of a Blob.
BlobShape()
The BlobShape constructor.
List< int > dim
The blob shape dimensions.
int axis
The axis along which to concatenate – may be negative to index from the end (e.g.,...
Specifies the parameters for the EltwiseLayer.
EltwiseOp
Defines the operation to perform.
EltwiseOp operation
Specifies the element-wise operation.
Specifies the filler parameters used to create each Filler.
FillerParameter Clone()
Creates a new copy of this instance of the parameter.
FillerParameter weight_filler
The filler for the weights.
int axis
Specifies the first axis to be lumped into a single inner product computation; all preceding axes are...
FillerParameter bias_filler
The filler for the bias.
uint num_output
The number of outputs for the layer.
bool bias_term
Whether to have bias terms or not.
Specifies the base parameter for all layers.
LayerParameter()
Constructor for the parameter.
List< ParamSpec > parameters
Specifies the ParamSpec parameters of the LayerParameter.
SliceParameter slice_param
Returns the parameter set when initialized with LayerType.SLICE
string name
Specifies the name of this LayerParameter.
List< bool > propagate_down
Specifies whether or not the LayerParameter (or protions of) should be backpropagated.
ScaleParameter scale_param
Returns the parameter set when initialized with LayerType.SCALE
bool group_start
Specifies whether or not this node is the start of a new group - this is only used when rendering mod...
EltwiseParameter eltwise_param
Returns the parameter set when initialized with LayerType.ELTWISE
InputParameter input_param
Returns the parameter set when initialized with LayerType.INPUT
List< string > top
Specifies the active top connections (in the bottom, out the top)
ReshapeParameter reshape_param
Returns the parameter set when initialized with LayerType.RESHAPE
InnerProductParameter inner_product_param
Returns the parameter set when initialized with LayerType.INNERPRODUCT
ConcatParameter concat_param
Returns the parameter set when initialized with LayerType.CONCAT
RecurrentParameter recurrent_param
Returns the parameter set when initialized with LayerType.RECURRENT
List< string > bottom
Specifies the active bottom connections (in the bottom, out the top).
LayerType
Specifies the layer type.
virtual LayerParameter Clone(bool bCloneBlobs)
Creates a new copy of this instance of the parameter.
Specifies the parameters use to create a Net
List< LayerParameter > layer
The layers that make up the net. Each of their configurations, including connectivity and behavior,...
Specifies training parameters (multipliers on global learning constants, and the name of other settin...
uint num_output
The dimension of the output (and usually hidden state) representation – must be explicitly set to non...
FillerParameter weight_filler
The filler for the weights.
FillerParameter bias_filler
The filler for the bias.
BlobShape shape
Specifies the output dimensions.
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.
The MyCaffe.common namespace contains common MyCaffe classes.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe.layers namespace contains all layers that have a solidified code base,...
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-...