8 #ifndef BLACKCATTENSORS_NEURALNETWORKS_LAYERS_FEEDFORWARD_H_ 9 #define BLACKCATTENSORS_NEURALNETWORKS_LAYERS_FEEDFORWARD_H_ 19 class Optimizer=Stochastic_Gradient_Descent>
22 FeedForward<SystemTag, ValueType, Optimizer>,
23 Tensor_Descriptor<ValueType, SystemTag, Integer<1>>>
43 using mat_opt_t =
typename Optimizer::template Optimizer<mat>;
44 using vec_opt_t =
typename Optimizer::template Optimizer<vec>;
63 w_gradients(outputs, inputs),
74 template<
class Matrix>
80 template<
class X,
class Delta>
83 w_gradients -= dy * x.
t();
96 w_opt.update(w, w_gradients);
99 b_opt.update(b, b_gradients);
107 w_opt.save(loader,
"w_opt");
108 b_opt.save(loader,
"b_opt");
115 w_opt.load(loader,
"w_opt");
116 b_opt.save(loader,
"b_opt");
120 template<
class SystemTag,
class Optimizer=nn_default_optimizer_type>
122 using value_type =
typename SystemTag::default_floating_point_type;
126 template<
class Optimizer=nn_default_optimizer_type>
127 auto feedforward(
int inputs,
int outputs, Optimizer=Optimizer()) {
129 using value_type =
typename system_tag::default_floating_point_type;
void randomize(value_type lb=0, value_type ub=1)
Definition: tensor_base.h:36
std::true_type greedy_evaluate_delta
Definition: feedforward.h:36
self_type & zero()
Definition: tensor_base.h:13
Definition: layer_base.h:86
#define BLACKCAT_DEFAULT_SYSTEM_T
Definition: common.h:49
Definition: layer_loader.h:19
virtual void set_learning_rate_hook(value_type lr) override
Definition: feedforward.h:88
void save_variable(const T &tensor, string variable_name)
Definition: layer_loader.h:44
auto forward_propagation(const Matrix &x)
Definition: feedforward.h:75
Definition: feedforward.h:20
virtual void save(Layer_Loader &loader) const override
Definition: feedforward.h:103
FeedForward(bc::size_t inputs, bc::size_t outputs)
Definition: feedforward.h:59
auto back_propagation(const X &x, const Delta &dy)
Definition: feedforward.h:81
int size_t
Definition: common.h:283
const auto t() const
Definition: expression_base.h:94
void load_variable(T &tensor, string variable_name)
Definition: layer_loader.h:50
SystemTag system_tag
Definition: feedforward.h:25
auto get_batched_learning_rate() const
Definition: layer_base.h:171
Optimizer optimizer_type
Definition: feedforward.h:34
ValueType value_type
Definition: feedforward.h:26
static constexpr value_type default_learning_rate
Definition: layer_base.h:107
void update_weights()
Definition: feedforward.h:94
auto feedforward(SystemTag system_tag, int inputs, int outputs, Optimizer=Optimizer())
Definition: feedforward.h:121
virtual void load(Layer_Loader &loader) override
Definition: feedforward.h:111
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22
Definition: recycle_allocator.h:57