1 #ifndef CAFFE_RECURRENT_LAYER_HPP_
2 #define CAFFE_RECURRENT_LAYER_HPP_
8 #include "caffe/blob.hpp"
9 #include "caffe/common.hpp"
10 #include "caffe/layer.hpp"
11 #include "caffe/net.hpp"
12 #include "caffe/proto/caffe.pb.h"
13 #include "caffe/util/format.hpp"
17 template <
typename Dtype>
class RecurrentLayer;
25 template <
typename Dtype>
30 virtual void LayerSetUp(
const vector<
Blob<Dtype>*>& bottom,
32 virtual void Reshape(
const vector<
Blob<Dtype>*>& bottom,
36 virtual inline const char* type()
const {
return "Recurrent"; }
37 virtual inline int MinBottomBlobs()
const {
39 if (this->layer_param_.recurrent_param().expose_hidden()) {
40 vector<string> inputs;
42 min_bottoms += inputs.size();
46 virtual inline int MaxBottomBlobs()
const {
return MinBottomBlobs() + 1; }
47 virtual inline int ExactNumTopBlobs()
const {
49 if (this->layer_param_.recurrent_param().expose_hidden()) {
50 vector<string> outputs;
52 num_tops += outputs.size();
57 virtual inline bool AllowForceBackward(
const int bottom_index)
const {
59 return bottom_index != 1;
145 virtual void Forward_gpu(
const vector<
Blob<Dtype>*>& bottom,
147 virtual void Backward_cpu(
const vector<
Blob<Dtype>*>& top,
148 const vector<bool>& propagate_down,
const vector<
Blob<Dtype>*>& bottom);
177 vector<Blob<Dtype>* > recur_input_blobs_;
178 vector<Blob<Dtype>* > recur_output_blobs_;
179 vector<Blob<Dtype>* > output_blobs_;
187 #endif // CAFFE_RECURRENT_LAYER_HPP_
int last_layer_index_
The last layer to run in the network. (Any later layers are losses added to force the recurrent net t...
Definition: recurrent_layer.hpp:169
shared_ptr< Net< Dtype > > unrolled_net_
A Net to implement the Recurrent functionality.
Definition: recurrent_layer.hpp:151
virtual void RecurrentInputBlobNames(vector< string > *names) const =0
Fills names with the names of the 0th timestep recurrent input Blob&s. Subclasses should define this ...
An abstract class for implementing recurrent behavior inside of an unrolled network....
Definition: recurrent_layer.hpp:26
bool static_input_
Whether the layer has a "static" input copied across all timesteps.
Definition: recurrent_layer.hpp:163
virtual void FillUnrolledNet(NetParameter *net_param) const =0
Fills net_param with the recurrent network architecture. Subclasses should define this – see RNNLayer...
virtual void OutputBlobNames(vector< string > *names) const =0
Fills names with the names of the output blobs, concatenated across all timesteps....
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers,...
Definition: blob.hpp:24
An interface for the units of computation which can be composed into a Net.
Definition: layer.hpp:33
virtual void RecurrentOutputBlobNames(vector< string > *names) const =0
Fills names with the names of the Tth timestep recurrent output Blob&s. Subclasses should define this...
virtual void RecurrentInputShapes(vector< BlobShape > *shapes) const =0
Fills shapes with the shapes of the recurrent input Blob&s. Subclasses should define this – see RNNLa...
int N_
The number of independent streams to process simultaneously.
Definition: recurrent_layer.hpp:154
bool expose_hidden_
Whether the layer's hidden state at the first and last timesteps are layer inputs and outputs,...
Definition: recurrent_layer.hpp:175
int T_
The number of timesteps in the layer's input, and the number of timesteps over which to backpropagate...
Definition: recurrent_layer.hpp:160
virtual void Forward_cpu(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Definition: recurrent_layer.cpp:246
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14