1 #ifndef CAFFE_LSTM_LAYER_HPP_
2 #define CAFFE_LSTM_LAYER_HPP_
8 #include "caffe/blob.hpp"
9 #include "caffe/common.hpp"
10 #include "caffe/layer.hpp"
11 #include "caffe/layers/recurrent_layer.hpp"
12 #include "caffe/net.hpp"
13 #include "caffe/proto/caffe.pb.h"
17 template <
typename Dtype>
class RecurrentLayer;
47 template <
typename Dtype>
50 explicit LSTMLayer(
const LayerParameter& param)
53 virtual inline const char* type()
const {
return "LSTM"; }
68 template <
typename Dtype>
76 virtual inline const char*
type()
const {
return "LSTMUnit"; }
82 return bottom_index != 2;
143 const vector<bool>& propagate_down,
const vector<
Blob<Dtype>*>& bottom);
145 const vector<bool>& propagate_down,
const vector<
Blob<Dtype>*>& bottom);
154 #endif // CAFFE_LSTM_LAYER_HPP_
Processes sequential inputs using a "Long Short-Term Memory" (LSTM) [1] style recurrent neural networ...
Definition: lstm_layer.hpp:48
An abstract class for implementing recurrent behavior inside of an unrolled network....
Definition: recurrent_layer.hpp:26
virtual void OutputBlobNames(vector< string > *names) const
Fills names with the names of the output blobs, concatenated across all timesteps....
Definition: lstm_layer.cpp:41
virtual void Backward_cpu(const vector< Blob< Dtype > * > &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > * > &bottom)
Computes the error gradient w.r.t. the LSTMUnit inputs.
Definition: lstm_unit_layer.cpp:72
virtual int ExactNumTopBlobs() const
Returns the exact number of top blobs required by the layer, or -1 if no exact number is required.
Definition: lstm_layer.hpp:78
virtual void RecurrentInputShapes(vector< BlobShape > *shapes) const
Fills shapes with the shapes of the recurrent input Blob&s. Subclasses should define this – see RNNLa...
Definition: lstm_layer.cpp:28
virtual void Forward_gpu(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Using the GPU device, compute the layer output. Fall back to Forward_cpu() if unavailable.
virtual void RecurrentOutputBlobNames(vector< string > *names) const
Fills names with the names of the Tth timestep recurrent output Blob&s. Subclasses should define this...
Definition: lstm_layer.cpp:21
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers,...
Definition: blob.hpp:24
virtual void Forward_cpu(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Definition: lstm_unit_layer.cpp:41
virtual void Backward_gpu(const vector< Blob< Dtype > * > &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > * > &bottom)
Using the GPU device, compute the gradients for any parameters and for the bottom blobs if propagate_...
An interface for the units of computation which can be composed into a Net.
Definition: layer.hpp:33
virtual void FillUnrolledNet(NetParameter *net_param) const
Fills net_param with the recurrent network architecture. Subclasses should define this – see RNNLayer...
Definition: lstm_layer.cpp:47
A helper for LSTMLayer: computes a single timestep of the non-linearity of the LSTM,...
Definition: lstm_layer.hpp:69
virtual void RecurrentInputBlobNames(vector< string > *names) const
Fills names with the names of the 0th timestep recurrent input Blob&s. Subclasses should define this ...
Definition: lstm_layer.cpp:14
virtual int ExactNumBottomBlobs() const
Returns the exact number of bottom blobs required by the layer, or -1 if no exact number is required.
Definition: lstm_layer.hpp:77
virtual const char * type() const
Returns the layer type.
Definition: lstm_layer.hpp:76
virtual bool AllowForceBackward(const int bottom_index) const
Return whether to allow force_backward for a given bottom blob index.
Definition: lstm_layer.hpp:80
int hidden_dim_
The hidden and output dimension.
Definition: lstm_layer.hpp:148
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
virtual void Reshape(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Adjust the shapes of top blobs and internal buffers to accommodate the shapes of the bottom blobs.
Definition: lstm_unit_layer.cpp:21