|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef STACK_HH_TAURECTOOLS
6 #define STACK_HH_TAURECTOOLS
29 #include <Eigen/Dense>
37 using Eigen::VectorXd;
38 using Eigen::MatrixXd;
41 class IRecurrentLayer;
53 Stack(
size_t n_inputs,
const std::vector<LayerConfig>&
layers,
54 size_t skip_layers = 0);
61 VectorXd
compute(VectorXd)
const;
82 virtual VectorXd
compute(
const VectorXd&)
const = 0;
88 virtual VectorXd
compute(
const VectorXd&)
const override;
95 virtual VectorXd
compute(
const VectorXd&)
const override;
103 virtual VectorXd
compute(
const VectorXd&)
const override;
110 BiasLayer(
const std::vector<double>& bias);
111 virtual VectorXd
compute(
const VectorXd&)
const override;
120 virtual VectorXd
compute(
const VectorXd&)
const override;
129 MaxoutLayer(
const std::vector<InitUnit>& maxout_tensor);
130 virtual VectorXd
compute(
const VectorXd&)
const override;
144 virtual VectorXd
compute(
const VectorXd&)
const override;
158 const MatrixXd& W_carry,
159 const VectorXd& b_carry,
161 virtual VectorXd
compute(
const VectorXd&)
const override;
216 virtual MatrixXd
scan(
const MatrixXd&)
const = 0;
227 virtual MatrixXd
scan(
const MatrixXd&)
const override;
241 const MatrixXd & W_i,
const MatrixXd & U_i,
const VectorXd & b_i,
242 const MatrixXd & W_f,
const MatrixXd & U_f,
const VectorXd & b_f,
243 const MatrixXd & W_o,
const MatrixXd & U_o,
const VectorXd & b_o,
244 const MatrixXd & W_c,
const MatrixXd & U_c,
const VectorXd & b_c,
246 bool return_sequence);
249 virtual MatrixXd
scan(
const MatrixXd&)
const override;
282 const MatrixXd & W_z,
const MatrixXd & U_z,
const VectorXd & b_z,
283 const MatrixXd & W_r,
const MatrixXd & U_r,
const VectorXd & b_r,
284 const MatrixXd & W_h,
const MatrixXd & U_h,
const VectorXd & b_h);
287 virtual MatrixXd
scan(
const MatrixXd&)
const override;
314 std::unique_ptr<IRecurrentLayer> backward_layer,
315 const std::string& merge_mode,
316 bool return_sequence);
319 virtual MatrixXd
scan(
const MatrixXd&)
const override;
390 #endif // STACK_HH_TAURECTOOLS
virtual ~IRecurrentLayer()
virtual VectorXd compute(const VectorXd &) const override
std::unique_ptr< const IRecurrentLayer > m_backward_layer
UnaryActivationLayer(ActivationConfig)
LSTMLayer(const ActivationConfig &activation, const ActivationConfig &inner_activation, const MatrixXd &W_i, const MatrixXd &U_i, const VectorXd &b_i, const MatrixXd &W_f, const MatrixXd &U_f, const VectorXd &b_f, const MatrixXd &W_o, const MatrixXd &U_o, const VectorXd &b_o, const MatrixXd &W_c, const MatrixXd &U_c, const VectorXd &b_c, bool go_backwards, bool return_sequence)
MatrixXd scan(MatrixXd inputs) const
HighwayLayer(const MatrixXd &W, const VectorXd &b, const MatrixXd &W_carry, const VectorXd &b_carry, ActivationConfig activation)
std::function< double(double)> m_inner_activation_fun
MatrixXd build_matrix(const std::vector< double > &weights, size_t n_inputs)
std::unique_ptr< const IRecurrentLayer > m_forward_layer
double nn_sigmoid(double x)
virtual VectorXd compute(const VectorXd &) const override
virtual MatrixXd scan(const MatrixXd &) const =0
virtual VectorXd compute(const VectorXd &) const =0
ReductionStack(size_t n_in, const std::vector< LayerConfig > &layers)
size_t add_highway_layers(size_t n_inputs, const LayerConfig &)
std::function< double(double)> m_activation_fun
BiasLayer(const VectorXd &bias)
size_t add_dense_layers(size_t n_inputs, const LayerConfig &)
double operator()(double) const
RecurrentStack * m_recurrent
GRULayer(const ActivationConfig &activation, const ActivationConfig &inner_activation, const MatrixXd &W_z, const MatrixXd &U_z, const VectorXd &b_z, const MatrixXd &W_r, const MatrixXd &U_r, const VectorXd &b_r, const MatrixXd &W_h, const MatrixXd &U_h, const VectorXd &b_h)
std::function< double(double)> m_act
std::function< double(double)> m_inner_activation_fun
virtual VectorXd compute(const VectorXd &) const override
ReductionStack(ReductionStack &)=delete
size_t add_embedding_layers(size_t n_inputs, const LayerConfig &)
double nn_hard_sigmoid(double x)
size_t add_bidirectional_layers(size_t n_inputs, const LayerConfig &)
void step(const VectorXd &input, GRUState &) const
RecurrentStack(RecurrentStack &)=delete
std::vector< ILayer * > m_layers
std::function< double(double)> m_activation_fun
NormalizationLayer(const VectorXd &W, const VectorXd &b)
virtual VectorXd compute(const VectorXd &) const override
MaxoutLayer(const std::vector< InitUnit > &maxout_tensor)
size_t add_layers(size_t n_inputs, const LayerConfig &)
void step(const VectorXd &input, LSTMState &) const
VectorXd build_vector(const std::vector< double > &bias)
std::function< double(double)> m_func
ReductionStack & operator=(ReductionStack &)=delete
virtual VectorXd compute(const VectorXd &) const override
BidirectionalLayer(std::unique_ptr< IRecurrentLayer > forward_layer, std::unique_ptr< IRecurrentLayer > backward_layer, const std::string &merge_mode, bool return_sequence)
bidirectional layer ///
VectorXd reduce(MatrixXd inputs) const
void throw_if_not_dense(const LayerConfig &layer)
std::vector< MatrixXd > m_matrices
virtual MatrixXd scan(const MatrixXd &) const override
virtual VectorXd compute(const VectorXd &) const override
MatrixLayer(const MatrixXd &matrix)
size_t add_lstm_layers(size_t n_inputs, const LayerConfig &)
virtual MatrixXd scan(const MatrixXd &) const override
void throw_if_not_normalization(const LayerConfig &layer)
RecurrentStack(size_t n_inputs, const std::vector< LayerConfig > &layers)
std::function< double(double)> get_activation(lwtDev::ActivationConfig act)
EmbeddingLayer(int var_row_index, const MatrixXd &W)
DenseComponents get_component(const lwtDev::LayerConfig &layer, size_t n_in)
Normalization layer /// https://arxiv.org/abs/1502.03167 ///.
virtual VectorXd compute(const VectorXd &) const override
size_t add_maxout_layers(size_t n_inputs, const LayerConfig &)
virtual MatrixXd scan(const MatrixXd &) const override
virtual ~EmbeddingLayer()
virtual MatrixXd scan(const MatrixXd &) const override
virtual ~BidirectionalLayer()
double operator()(double) const
void throw_if_not_maxout(const LayerConfig &layer)
std::vector< IRecurrentLayer * > m_layers
std::pair< MatrixXd, VectorXd > InitUnit
size_t add_normalization_layers(size_t n_inputs, const LayerConfig &)
VectorXd compute(VectorXd) const
double operator()(double) const
virtual VectorXd compute(const VectorXd &) const override
Stack & operator=(Stack &)=delete
RecurrentStack & operator=(RecurrentStack &)=delete
ILayer * get_raw_activation_layer(ActivationConfig activation)
size_t add_gru_layers(size_t n_inputs, const LayerConfig &)