rf_diag.hpp

00001 //
00002 //  Copyright (c) 2005-2007
00003 //  James N Knight
00004 //
00005 //  Permission to use, copy, modify, distribute and sell this software
00006 //  and its documentation for any purpose is hereby granted without fee,
00007 //  provided that the above copyright notice appear in all copies and
00008 //  that both that copyright notice and this permission notice appear
00009 //  in supporting documentation.  The authors make no representations
00010 //  about the suitability of this software for any purpose.
00011 //  It is provided "as is" without express or implied warranty.
00012 //
00013 //  
00014 // See http://homepages.inf.ed.ac.uk/svijayak/publications/vijayakumar-NeuCom2005.pdf
00015 // for the original publication of this algorithm.
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     // temp variables
00083     Types::vector dwdM, dJ2dM, dJdM;
00084     
00085     // meta learning temp vars
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         //const_cast<Types::vector&>(temp2) = element_prod(M,(x-center));
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         //return exp(-0.5 * ublas::prec_inner_prod(temp2,temp2)); 
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

Generated on Fri Jul 27 00:24:01 2007 for LWPR by  doxygen 1.5.1