![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
RLSRandFeats is the sub-class of Optimizer that computes a classifier for the primal formulation of RLS using the Random Features approach proposed in: Ali Rahimi, Ben Recht; Random Features for Large-Scale Kernel Machines; in Neural Information Processing Systems (NIPS) 2007. More...
#include <rlsrandfeats.h>
Public Member Functions | |
GurlsOptionsList * | execute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) |
Computes a classifier for the primal formulation of RLS using the Random Features approach. | |
Static Public Member Functions | |
static Optimizer< T > * | factory (const std::string &id) throw (BadOptimizerCreation) |
Factory function returning a pointer to the newly created object. |
The regularization parameter is set to the one found in opt.paramsel. In case of multiclass problems, the regularizers need to be combined with the opt.singlelambda function.
Definition at line 70 of file rlsrandfeats.h.
GurlsOptionsList * gurls::RLSRandFeats< T >::execute | ( | const gMat2D< T > & | X, |
const gMat2D< T > & | Y, | ||
const GurlsOptionsList & | opt | ||
) | [virtual] |
X | input data matrix |
Y | labels matrix |
struct | of options with the following fields:
|
Implements gurls::Optimizer< T >.
Definition at line 94 of file rlsrandfeats.h.
{ // lambda = opt.singlelambda(opt.paramsel.lambdas); const gMat2D<T> &ll = opt.getOptValue<OptMatrix<gMat2D<T> > >("paramsel.lambdas"); T lambda = opt.getOptAs<OptFunction>("singlelambda")->getValue(ll.getData(), ll.getSize()); const unsigned long sampleSize = opt.getOptAsNumber("randfeats.samplesize"); const unsigned long D = opt.getOptAsNumber("randfeats.D"); // n = size(X,1); const unsigned long n = X.rows(); // const unsigned long d = X.cols(); const unsigned long t = Y.cols(); // if or(opt.randfeats.samplesize < 0, opt.randfeats.samplesize > n) // ni = n; // else // ni = opt.randfeats.samplesize; // end const unsigned long ni = (sampleSize < 0 || sampleSize > n)? n : sampleSize; const unsigned long D2 = 2*D; T *XtX = new T[D2*D2]; T *Xty = new T[D2*t]; // [XtX,Xty,rls.proj] = rp_factorize_large_real(X,y,opt.randfeats.D,ni); gMat2D<T> *rls_proj = rp_factorize_large_real(X, Y, D, ni, XtX, Xty); // rls.W = rls_primal_driver( XtX, Xty, n, lambda ); gMat2D<T> *W = rls_primal_driver(XtX, Xty, D2, D2, t, lambda); delete [] XtX; delete [] Xty; GurlsOptionsList *optimizer = new GurlsOptionsList("optimizer"); optimizer->addOpt("proj", new OptMatrix<gMat2D<T> >(*rls_proj)); // rls.W = rls_primal_driver( XtX, Xty, n, lambda ); optimizer->addOpt("W", new OptMatrix<gMat2D<T> >(*W)); // rls.C = []; gMat2D<T>* emptyC = new gMat2D<T>(); optimizer->addOpt("C", new OptMatrix<gMat2D<T> >(*emptyC)); // rls.X = []; gMat2D<T>* emptyX = new gMat2D<T>(); optimizer->addOpt("X", new OptMatrix<gMat2D<T> >(*emptyX)); return optimizer; }
static Optimizer<T>* gurls::Optimizer< T >::factory | ( | const std::string & | id | ) | throw (BadOptimizerCreation) [inline, static, inherited] |
Definition at line 130 of file optimization.h.
{ if(id == "rlsauto") return new RLSAuto<T>; if(id == "rlsprimal") return new RLSPrimal<T>; if(id == "rlsprimalr") return new RLSPrimalr<T>; if(id == "rlsdual") return new RLSDual<T>; if(id == "rlsdualr") return new RLSDualr<T>; if(id == "rlspegasos") return new RLSPegasos<T>; if(id == "rlsgpregr") return new RLSGPRegr<T>; if(id == "rlsprimalrecinit") return new RLSPrimalRecInit<T>; if(id == "rlsprimalrecupdate") return new RLSPrimalRecUpdate<T>; if(id == "rlsrandfeats") return new RLSRandFeats<T>; throw BadOptimizerCreation(id); }