2using System.Collections.Generic;
5using System.Threading.Tasks;
57 : base(cuda, log, p, evtCancel)
79 rgNames.Add(
"h_" +
m_nT.ToString());
115 m_log.
CHECK_GT(nNumOutput, 0,
"num_output must be positive.");
142 List<BlobShape> rgInputShapes =
new List<BlobShape>();
144 m_log.
CHECK_EQ(1, rgInputShapes.Count,
"There should only be one input shape.");
150 input_layer_param.
top.Add(
"h_0");
152 net_param.
layer.Add(input_layer_param);
155 cont_slice_param.
name =
"cont_slice";
156 cont_slice_param.
bottom.Add(
"cont");
158 net_param.
layer.Add(cont_slice_param);
164 x_transform_param.
name =
"x_transform";
167 x_transform_param.
bottom.Add(
"x");
168 x_transform_param.
top.Add(
"W_xh_x");
170 net_param.
layer.Add(x_transform_param);
179 x_static_transform_param.
name =
"W_xh_x_static";
181 x_static_transform_param.
bottom.Add(
"x_static");
182 x_static_transform_param.
top.Add(
"W_xh_x_static_preshape");
184 net_param.
layer.Add(x_static_transform_param);
188 new_shape.
dim.Add(1);
189 new_shape.
dim.Add(-1);
191 reshape_param.
name =
"W_xh_x_static_reshape";
192 reshape_param.
bottom.Add(
"W_xh_x_static_preshape");
193 reshape_param.
top.Add(
"W_xh_x_static");
194 net_param.
layer.Add(reshape_param);
198 x_slice_param.
name =
"W_xh_x_slice";
199 x_slice_param.
bottom.Add(
"W_xh_x");
200 net_param.
layer.Add(x_slice_param);
203 output_concat_layer.
name =
"o_concat";
204 output_concat_layer.
top.Add(
"o");
207 for (
int t = 1; t <=
m_nT; t++)
209 string tm1s = (t - 1).ToString();
210 string ts = t.ToString();
212 cont_slice_param.
top.Add(
"cont_" + ts);
213 x_slice_param.
top.Add(
"W_xh_x_" + ts);
225 cont_h_param.
name =
"h_conted_" + tm1s;
226 cont_h_param.
bottom.Add(
"h_" + tm1s);
227 cont_h_param.
bottom.Add(
"cont_" + ts);
228 cont_h_param.
top.Add(
"h_conted_" + tm1s);
229 net_param.
layer.Add(cont_h_param);
236 w_param.
name =
"W_hh_h_" + tm1s;
238 w_param.
bottom.Add(
"h_conted_" + tm1s);
239 w_param.
top.Add(
"W_hh_h_" + tm1s);
241 net_param.
layer.Add(w_param);
249 h_input_sum_param.
name =
"h_input_sum_" + ts;
250 h_input_sum_param.
bottom.Add(
"W_hh_h_" + tm1s);
251 h_input_sum_param.
bottom.Add(
"W_xh_x_" + ts);
254 h_input_sum_param.
bottom.Add(
"W_xh_x_static");
256 h_input_sum_param.
top.Add(
"h_neuron_input_" + ts);
257 net_param.
layer.Add(h_input_sum_param);
261 h_neuron_param.
name =
"h_neuron_input_" + ts;
262 h_neuron_param.
bottom.Add(
"h_neuron_input_" + ts);
263 h_neuron_param.
top.Add(
"h_" + ts);
264 net_param.
layer.Add(h_neuron_param);
271 w_param.
name =
"W_ho_h_" + ts;
274 w_param.
bottom.Add(
"h_" + ts);
275 w_param.
top.Add(
"W_ho_h_" + ts);
277 net_param.
layer.Add(w_param);
285 o_neuron_param.
name =
"o_neuron_" + ts;
286 o_neuron_param.
bottom.Add(
"W_ho_h_" + ts);
287 o_neuron_param.
top.Add(
"o_" + ts);
288 net_param.
layer.Add(o_neuron_param);
291 output_concat_layer.
bottom.Add(
"o_" + ts);
294 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.
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 RNNLayer processes time-varying inputs using a simple recurrent neural network (RNN)....
override void RecurrentOutputBlobNames(List< string > rgNames)
Fills the rgNames array with names of the Tth timestep recurrent output Blobs.
override void FillUnrolledNet(NetParameter net_param)
Fills the NetParameter with the RNN network architecture.
override void RecurrentInputShapes(List< BlobShape > rgShapes)
Fill the rgShapes array with the shapes of the recurrent input Blobs.
override void OutputBlobNames(List< string > rgNames)
Fills the rgNames array with the names of the output Blobs, concatenated across all timesteps.
RNNLayer(CudaDnn< T > cuda, Log log, LayerParameter p, CancelEvent evtCancel)
The RNNLayer constructor.
override void RecurrentInputBlobNames(List< string > rgNames)
Fills the rgNames array with the names of the 0th timestep recurrent input Blobs.
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
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-...