00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RF_DIAG_HPP
00020 #define RF_DIAG_HPP
00021
00022 #include <math.h>
00023
00024 #include <boost/numeric/ublas/vector_expression.hpp>
00025 #include <boost/numeric/ublas/io.hpp>
00026 #include <boost/program_options.hpp>
00027
00028 #include <fstream>
00029
00030 #include "types.hpp"
00031 #include "rf.hpp"
00032
00033
00040 class RFDiag : public RF {
00041
00050
00054 Types::vector alpha;
00055
00059 Types::vector meta_h,b;
00060
00062
00063
00072
00074 Types::vector D;
00075
00077 Types::vector M;
00078
00080
00081
00082
00083 Types::vector dwdM, dJ2dM, dJdM;
00084
00085
00086 Types::vector dJ2_2dM_2, aux, dw_2dM_2, dJ_2dM_2;
00087
00088 public:
00089
00091 RFDiag();
00092
00098 RFDiag(Types::Input c);
00099
00103 RFDiag(Types::Input c, const boost::program_options::variables_map& vm);
00104
00108 RFDiag(const RFDiag&, Types::Input c, const boost::program_options::variables_map& vm);
00109
00116 virtual Types::RValue getActivation(Types::Input x) const
00117 {
00118
00119 Types::RValue act = 0.0;
00120
00121 for(int i=0; i<M.size(); ++i)
00122 act += M(i)*(x(i)-center(i))*M(i)*(x(i)-center(i));
00123
00124 return exp(-0.5 * act);
00125
00126 };
00127
00128
00139 virtual Types::RValue learn(Types::Input x, Types::Output y, Types::RValueP w);
00140
00144 friend std::ostream& operator<<(std::ostream& out, const RFDiag& rf);
00145
00149 Types::Input getAlpha() const { return alpha; };
00150 Types::Input getD() const { return D; };
00151 Types::Input getM() const { return M; };
00152 Types::Input getCenter() const { return center; };
00153
00154
00155 };
00156
00157 #endif