Tenncor
err_approx.hpp
Go to the documentation of this file.
1 
9 #include <unordered_map>
10 
11 #include "eteq/generated/pyapi.hpp"
12 
13 #include "eteq/constant.hpp"
14 #include "eteq/variable.hpp"
15 #include "eteq/session.hpp"
16 
17 #ifndef LAYR_ERR_APPROX_HPP
18 #define LAYR_ERR_APPROX_HPP
19 
20 namespace layr
21 {
22 
24 using VarErrsT = std::vector<std::pair<eteq::VarptrT<PybindT>,NodeptrT>>;
25 
27 struct VarAssign
28 {
30  std::string label_;
31 
34 
37 };
38 
40 using AssignsT = std::vector<VarAssign>;
41 
43 using AssignGroupsT = std::vector<AssignsT>;
44 
47 using ApproxF = std::function<AssignGroupsT(const VarErrsT&)>;
48 
51 using UpdateStepF = std::function<void(teq::TensSetT&)>;
52 
62 AssignGroupsT sgd (const VarErrsT& leaves,
63  PybindT learning_rate = 0.5, std::string root_label = "");
64 
77 AssignGroupsT rms_momentum (const VarErrsT& leaves,
78  PybindT learning_rate = 0.5, PybindT discount_factor = 0.99,
79  PybindT epsilon = std::numeric_limits<PybindT>::epsilon(),
80  std::string root_label = "");
81 
83 void assign_groups (const AssignGroupsT& groups, UpdateStepF update_step);
84 
86 void assign_groups_preupdate (const AssignGroupsT& groups, UpdateStepF update_step);
87 
88 }
89 
90 #endif // LAYR_ERR_APPROX_HPP
std::shared_ptr< VariableNode< T > > VarptrT
Smart pointer of variable nodes to preserve assign functions.
Definition: variable.hpp:210
NodeptrT source_
Variable update as to minimize the error in future iterations.
Definition: err_approx.hpp:36
std::string label_
Representation of assignment.
Definition: err_approx.hpp:30
Definition: conv.hpp:16
void assign_groups_preupdate(const AssignGroupsT &groups, UpdateStepF update_step)
Apply all batches of assignments with update_step applied before each batch.
Definition: err_approx.cpp:73
std::vector< std::pair< eteq::VarptrT< PybindT >, NodeptrT > > VarErrsT
Ordered association between variable and error.
Definition: err_approx.hpp:24
std::vector< VarAssign > AssignsT
One batch of assignments.
Definition: err_approx.hpp:40
AssignGroupsT sgd(const VarErrsT &leaves, PybindT learning_rate=0.5, std::string root_label="")
Definition: err_approx.cpp:10
void assign_groups(const AssignGroupsT &groups, UpdateStepF update_step)
Apply all batches of assignments with update_step applied after each batch.
Definition: err_approx.cpp:58
std::function< AssignGroupsT(const VarErrsT &)> ApproxF
Definition: err_approx.hpp:47
std::vector< AssignsT > AssignGroupsT
All batches of assignments.
Definition: err_approx.hpp:43
Variable and error approximation assignment encapsulation.
Definition: err_approx.hpp:27
AssignGroupsT rms_momentum(const VarErrsT &leaves, PybindT learning_rate=0.5, PybindT discount_factor=0.99, PybindT epsilon=std::numeric_limits< PybindT >::epsilon(), std::string root_label="")
Definition: err_approx.cpp:27
std::function< void(teq::TensSetT &)> UpdateStepF
Definition: err_approx.hpp:51
std::shared_ptr< iNode< T > > NodeptrT
Smart pointer of node.
Definition: inode.hpp:63
eteq::VarptrT< PybindT > target_
Variable to assign to.
Definition: err_approx.hpp:33