8 #ifndef RECURRENT_FEEDFORWARD_CU_ 9 #define RECURRENT_FEEDFORWARD_CU_ 16 template<
class SystemTag,
class ValueType,
class RecurrentNonLinearity=bc::Tanh>
19 Recurrent<SystemTag, ValueType, RecurrentNonLinearity>,
20 Tensor_Descriptor<ValueType, SystemTag, Integer<1>>> {
38 RecurrentNonLinearity g;
51 w_gradients(outputs, inputs),
53 r_gradients(outputs, outputs),
68 template<
class X,
class Y>
70 return w * x + r * g(y) + b;
73 template<
class X,
class Y,
class Delta>
75 r_gradients -= dc * g.dx(y).
t();
77 dc.
alias() = dy + r.
t() * dc;
78 w_gradients -= dy * x.
t();
86 w += w_gradients * lr;
87 b += b_gradients * lr;
88 r += r_gradients * lr;
123 template<
class ValueType,
class SystemTag>
129 template<
class SystemTag>
136 typename BLACKCAT_DEFAULT_SYSTEM_T::default_floating_point_type>(inputs, outputs);
void update_weights()
Definition: recurrent.h:83
void randomize(value_type lb=0, value_type ub=1)
Definition: tensor_base.h:36
std::true_type greedy_evaluate_delta
Definition: recurrent.h:31
void set_batch_size_hook(bc::size_t bs)
Definition: recurrent.h:94
Recurrent< SystemTag, ValueType > recurrent(SystemTag system_tag, int inputs, int outputs)
Definition: recurrent.h:124
void zero_deltas()
Definition: recurrent.h:99
virtual void save(Layer_Loader &loader) const override
Definition: recurrent.h:109
virtual void load(Layer_Loader &loader)
Definition: recurrent.h:115
self_type & zero()
Definition: tensor_base.h:13
Recurrent(int inputs, int outputs)
Definition: recurrent.h:48
ValueType value_type
Definition: recurrent.h:23
std::true_type forward_requires_outputs
Definition: recurrent.h:29
Definition: layer_base.h:86
#define BLACKCAT_DEFAULT_SYSTEM_T
Definition: common.h:49
Definition: layer_loader.h:19
Definition: recurrent.h:17
void save_variable(const T &tensor, string variable_name)
Definition: layer_loader.h:44
std::true_type backward_requires_outputs
Definition: recurrent.h:30
auto forward_propagation(const X &x, const Y &y)
Definition: recurrent.h:69
Alias alias()
Definition: tensor_base.h:104
bc::size_t output_size() const
Definition: layer_base.h:148
int size_t
Definition: common.h:283
Definition: allocators.h:20
const auto t() const
Definition: expression_base.h:94
auto forward_propagation(const X &x)
Definition: recurrent.h:64
void load_variable(T &tensor, string variable_name)
Definition: layer_loader.h:50
bc::size_t batch_size() const
Definition: layer_base.h:149
void zero_gradients()
Definition: recurrent.h:103
SystemTag system_tag
Definition: recurrent.h:22
auto back_propagation(const X &x, const Y &y, const Delta &dy)
Definition: recurrent.h:74
static constexpr value_type default_learning_rate
Definition: layer_base.h:107
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22