File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed
Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,9 @@ void var::evaluateLeaves()const{
106106 auto &w1_shape = node.weights [0 ].shape ;
107107 auto &w2_shape = node.weights [1 ].shape ;
108108 if (node.type == matmul){
109- tape.grads [node.parents [0 ]] += gradient * node.weights [0 ].t ();
109+ tape.grads [node.parents [0 ]] += gradient * node.weights [0 ].t ();
110110 tape.grads [node.parents [1 ]] += node.weights [1 ].t () * gradient;
111+
111112 }
112113 else if (node.type == scalar){
113114 if (w1_shape == g_shape){
Original file line number Diff line number Diff line change @@ -14,11 +14,10 @@ void GD::step(){
1414 }
1515}
1616
17- /*
1817Moment::Moment (ParStack& p_list, double l_rate_, double moment_)
1918: Opt(p_list), l_rate(l_rate_), moment(moment_){
2019 for (auto &it : param_list){
21- m_list.emplace_front (nn::Tensor(it->data.shape, 0));
20+ m_list.push_back (nn::Tensor (it->data .shape , 0 ));
2221 }
2322}
2423
@@ -30,5 +29,4 @@ void Moment::step(){
3029 ++p_it;
3130 }
3231}
33- */
3432} // namespace opt
Original file line number Diff line number Diff line change 22#define OPTIM_H
33
44#include " net.hpp"
5+ #include < list>
56
67namespace opt {
78typedef std::forward_list<nn::Net::Parameter*> ParStack;
@@ -22,16 +23,16 @@ class GD: public Opt{
2223private:
2324 double l_rate;
2425};
25- /*
26+
2627class Moment : public Opt {
2728public:
2829 Moment (ParStack&, double = 0.1 , double = 0.9 );
2930 void step ();
3031 ~Moment (){};
3132private:
3233 double l_rate, moment;
33- std::forward_list <nn::Tensor> m_list;
34+ std::list <nn::Tensor> m_list;
3435};
35- */
36+
3637} // namespace opt
3738#endif // OPTIM_H
You can’t perform that action at this time.
0 commit comments