File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 66namespace nn {
77using autodiff::Var;
88
9+ /* *
10+ Net
11+ An abstract neural net object using automatic differentiation
12+ A forward function should be defined by the end-user within a child class
13+ */
914class Net {
1015 public:
16+ // Backpropigation using the chain rule and the AutoDiff module
1117 void backward (const Var &loss);
18+ // Parameter registration and creation
1219 Var& create_parameter (const Tensor& data) {
1320 parameters.push_front (Var (data));
1421 return parameters.front ();
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ namespace opt{
99using autodiff::Var;
1010typedef std::forward_list<Var> ParameterList;
1111
12+ /* *
13+ Opt
14+ Abstract optimiser storing a reference to a list of autodiff::Vars
15+ */
1216class Opt {
1317public:
1418 Opt (ParameterList&);
@@ -18,18 +22,28 @@ class Opt{
1822 ParameterList& parameters;
1923};
2024
25+ /* *
26+ GD
27+ Gradient descent optimisation of a ParameterList
28+ */
2129class GD : public Opt {
2230public:
2331 GD (ParameterList&, double = 0.1 );
32+ // One optimisation step
2433 void step ();
2534 ~GD (){};
2635private:
2736 double l_rate;
2837};
2938
39+ /* *
40+ Moment
41+ Gradient descent optimisation of a ParameterList with momentum
42+ */
3043class Moment : public Opt {
3144public:
3245 Moment (ParameterList&, double = 0.1 , double = 0.9 );
46+ // One optimisation step
3347 void step ();
3448 ~Moment (){}
3549private:
You can’t perform that action at this time.
0 commit comments