21 #define DRWN_UNROLL_FEATURE_MAP_LOOPS
57 virtual int numParameters()
const = 0;
61 _nFeatures = nFeatures;
65 virtual vector<double> operator()(
const vector<double>& x)
const = 0;
68 virtual double dot(
const vector<double>& theta,
const vector<double>& x)
const {
69 vector<double> phi((*
this)(x));
71 for (
unsigned i = 0; i < phi.size(); i++) {
72 v += phi[i] * theta[i];
78 virtual void mac(vector<double>& theta,
const vector<double>& x,
double alpha)
const {
79 const vector<double> phi((*
this)(x));
80 for (
unsigned i = 0; i < phi.size(); i++) {
81 theta[i] += alpha * phi[i];
96 const char *
type ()
const {
return "drwnIdentityFeatureMap"; }
108 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
109 return Eigen::Map<const VectorXd>(&theta[0],
110 theta.size()).dot(Eigen::Map<const VectorXd>(&x[0], x.size()));
114 void mac(vector<double>& theta,
const vector<double>& x,
double alpha)
const {
115 Eigen::Map<VectorXd>(&theta[0], theta.size()) += alpha *
116 Eigen::Map<const VectorXd>(&x[0], x.size());
130 const char *
type ()
const {
return "drwnBiasFeatureMap"; }
138 vector<double> phi(x.size() + 1);
139 copy(x.begin(), x.end(), phi.begin());
145 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
146 return theta.back() +
147 Eigen::Map<const VectorXd>(&theta[0],
148 theta.size() - 1).dot(Eigen::Map<const VectorXd>(&x[0], x.size()));
152 void mac(vector<double>& theta,
const vector<double>& x,
double alpha)
const {
153 Eigen::Map<VectorXd>(&theta[0], theta.size() - 1) += alpha *
154 Eigen::Map<const VectorXd>(&x[0], x.size());
155 theta.back() += alpha;
171 const char *
type ()
const {
return "drwnSquareFeatureMap"; }
179 vector<double> phi(2 * x.size() + 1);
180 copy(x.begin(), x.end(), phi.begin());
181 for (
unsigned i = 0; i < x.size(); i++) {
182 phi[x.size() + i] = M_SQRT1_2 * (x[i] * x[i] - 1.0);
189 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
190 double v = theta.back();
191 vector<double>::const_iterator it = theta.begin();
192 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
195 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
196 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
202 void mac(vector<double>& theta,
const vector<double>& x,
double alpha)
const {
203 Eigen::Map<ArrayXd>(&theta[0], _nFeatures) += alpha *
204 Eigen::Map<const ArrayXd>(&x[0], x.size());
205 Eigen::Map<ArrayXd>(&theta[_nFeatures], _nFeatures) += M_SQRT1_2 * alpha *
206 (Eigen::Map<const ArrayXd>(&x[0], x.size()).array().square() - 1.0);
207 theta.back() += alpha;
223 const char *
type ()
const {
return "drwnQuadraticFeatureMap"; }
231 vector<double> phi(2 * x.size() + 1);
232 copy(x.begin(), x.end(), phi.begin());
234 for (
unsigned i = 0; i < x.size(); i++) {
235 for (
unsigned j = 0; j < i; j++) {
236 phi[indx++] = x[i] * x[j];
238 phi[indx++] = M_SQRT1_2 * (x[i] * x[i] - 1.0);
245 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
246 double v = theta.back();
247 vector<double>::const_iterator it = theta.begin();
248 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
251 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
252 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
253 v += (*it) * (*ix) * (*jx);
255 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
261 void mac(vector<double>& theta,
const vector<double>& x,
double alpha)
const {
262 vector<double>::iterator it = theta.begin();
263 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
264 (*it) += alpha * (*ix);
266 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
267 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
268 (*it) += alpha * (*ix) * (*jx);
270 (*it) += alpha * M_SQRT1_2 * ((*ix) * (*ix) - 1.0);
272 theta.back() += alpha;
303 _nFeatures(nFeatures), _nClasses(nClasses) { }
314 virtual int numParameters()
const = 0;
318 _nFeatures = nFeatures; _nClasses = nClasses;
322 virtual vector<double> operator()(
const vector<double>& x,
int y)
const = 0;
325 virtual vector<double>
operator()(
const vector<double>& x)
const {
326 vector<double> phi(numParameters());
327 for (
int y = 0; y < _nClasses; y++) {
328 vector<double> phi_y((*
this)(x, y));
329 for (
unsigned i = 0; i < phi.size(); i++) {
337 virtual double dot(
const vector<double>& theta,
const vector<double>& x,
int y)
const {
338 vector<double> phi((*
this)(x, y));
340 for (
unsigned i = 0; i < phi.size(); i++) {
341 v += phi[i] * theta[i];
347 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
349 for (
int y = 0; y < _nClasses; y++) {
350 v += dot(theta, x, y);
356 virtual void mac(vector<double>& theta,
const vector<double>& x,
double alpha,
int y)
const {
357 const vector<double> phi((*
this)(x, y));
358 for (
unsigned i = 0; i < phi.size(); i++) {
359 theta[i] += alpha * phi[i];
364 virtual void mac(vector<double>& theta,
const vector<double>& x,
const vector<double>& alpha)
const {
365 for (
int y = 0; y < _nClasses; y++) {
366 const vector<double> phi((*
this)(x, y));
367 for (
unsigned i = 0; i < phi.size(); i++) {
368 theta[i] += alpha[y] * phi[i];
381 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
389 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
396 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
397 _nFeaturesDiv4 = nFeatures / 4;
398 _nFeaturesMod4 = nFeatures % 4;
404 const char *
type ()
const {
return "drwnIdentityJointFeatureMap"; }
408 int numParameters()
const {
return std::max(_nFeatures * (_nClasses - 1), 0); }
410 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
411 void initialize(
int nFeatures,
int nClasses) {
413 _nFeatures = nFeatures; _nClasses = nClasses;
414 _nFeaturesDiv4 = nFeatures / 4;
415 _nFeaturesMod4 = nFeatures % 4;
420 vector<double>
operator()(
const vector<double>& x,
int y)
const {
421 vector<double> phi(numParameters(), 0.0);
422 if (y != _nClasses - 1) {
423 copy(x.begin(), x.end(), phi.begin() + y * _nFeatures);
430 vector<double> phi(numParameters());
431 for (
int y = 0; y < _nClasses - 1; y++) {
432 copy(x.begin(), x.end(), phi.begin() + y * _nFeatures);
438 double dot(
const vector<double>& theta,
const vector<double>& x,
int y)
const {
439 if (y == _nClasses - 1)
return 0.0;
441 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
442 const double *it = &theta[y * _nFeatures];
443 const double *ix = &x[0];
444 for (
int i = _nFeaturesDiv4; i != 0; i--) {
445 v += it[0] * ix[0] + it[1] * ix[1] + it[2] * ix[2] + it[3] * ix[3];
448 for (
int i = 0; i < _nFeaturesMod4; i++, ++it, ++ix) {
452 vector<double>::const_iterator it = theta.begin() + y * _nFeatures;
453 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
461 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
463 vector<double>::const_iterator it = theta.begin();
464 for (
int y = 0; y < _nClasses - 1; y++) {
465 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
473 void mac(vector<double>& theta,
const vector<double>& x,
double alpha,
int y)
const {
474 if (y == _nClasses - 1)
return;
475 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
476 double *it = &theta[y * _nFeatures];
477 const double *ix = &x[0];
478 for (
int i = _nFeaturesDiv4; i != 0; i--) {
479 it[0] += alpha * ix[0];
480 it[1] += alpha * ix[1];
481 it[2] += alpha * ix[2];
482 it[3] += alpha * ix[3];
485 for (
int i = 0; i < _nFeaturesMod4; i++, ++it, ++ix) {
486 (*it) += alpha * (*ix);
489 vector<double>::iterator it = theta.begin() + y * _nFeatures;
490 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
491 (*it) += alpha * (*ix);
497 void mac(vector<double>& theta,
const vector<double>& x,
const vector<double>& alpha)
const {
498 vector<double>::iterator it = theta.begin();
499 for (
int y = 0; y < _nClasses - 1; y++) {
500 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
501 (*it) += alpha[y] * (*ix);
513 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
521 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
528 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
529 _nFeaturesDiv4 = nFeatures / 4;
530 _nFeaturesMod4 = nFeatures % 4;
536 const char *
type ()
const {
return "drwnBiasJointFeatureMap"; }
540 int numParameters()
const {
return std::max((_nFeatures + 1) * (_nClasses - 1), 0); }
542 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
543 void initialize(
int nFeatures,
int nClasses) {
545 _nFeatures = nFeatures; _nClasses = nClasses;
546 _nFeaturesDiv4 = nFeatures / 4;
547 _nFeaturesMod4 = nFeatures % 4;
552 vector<double>
operator()(
const vector<double>& x,
int y)
const {
553 vector<double> phi(numParameters(), 0.0);
554 if (y != _nClasses - 1) {
555 copy(x.begin(), x.end(), phi.begin() + y * (_nFeatures + 1));
556 phi[y * (_nFeatures + 1) + _nFeatures] = 1.0;
563 vector<double> phi(numParameters());
564 vector<double>::iterator it = phi.begin();
565 for (
int y = 0; y < _nClasses - 1; y++) {
566 copy(x.begin(), x.end(), it);
567 *(it += _nFeatures)++ = 1.0;
573 double dot(
const vector<double>& theta,
const vector<double>& x,
int y)
const {
574 if (y == _nClasses - 1)
return 0.0;
576 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
577 const double *it = &theta[y * (_nFeatures + 1)];
578 const double *ix = &x[0];
579 for (
int i = _nFeaturesDiv4; i != 0; i--) {
580 v += it[0] * ix[0] + it[1] * ix[1] + it[2] * ix[2] + it[3] * ix[3];
583 for (
int i = 0; i < _nFeaturesMod4; i++, ++it, ++ix) {
587 vector<double>::const_iterator it = theta.begin() + y * (_nFeatures + 1);
588 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
597 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
599 vector<double>::const_iterator it = theta.begin();
600 for (
int y = 0; y < _nClasses - 1; y++) {
601 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
610 void mac(vector<double>& theta,
const vector<double>& x,
double alpha,
int y)
const {
611 if (y == _nClasses - 1)
return;
612 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
613 double *it = &theta[y * (_nFeatures + 1)];
614 const double *ix = &x[0];
615 for (
int i = _nFeaturesDiv4; i != 0; i--) {
616 it[0] += alpha * ix[0];
617 it[1] += alpha * ix[1];
618 it[2] += alpha * ix[2];
619 it[3] += alpha * ix[3];
622 for (
int i = 0; i < _nFeaturesMod4; i++, ++it, ++ix) {
623 (*it) += alpha * (*ix);
626 vector<double>::iterator it = theta.begin() + y * (_nFeatures + 1);
627 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
628 (*it) += alpha * (*ix);
635 void mac(vector<double>& theta,
const vector<double>& x,
const vector<double>& alpha)
const {
636 vector<double>::iterator it = theta.begin();
637 for (
int y = 0; y < _nClasses - 1; y++) {
638 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
639 (*it) += alpha[y] * (*ix);
653 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
661 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
668 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
669 _nFeaturesDiv4 = nFeatures / 4;
670 _nFeaturesMod4 = nFeatures % 4;
676 const char *
type ()
const {
return "drwnSquareJointFeatureMap"; }
680 int numParameters()
const {
return std::max((2 * _nFeatures + 1) * (_nClasses - 1), 0); }
682 #ifdef DRWN_UNROLL_FEATURE_MAP_LOOPS
683 void initialize(
int nFeatures,
int nClasses) {
685 _nFeatures = nFeatures; _nClasses = nClasses;
686 _nFeaturesDiv4 = nFeatures / 4;
687 _nFeaturesMod4 = nFeatures % 4;
692 vector<double>
operator()(
const vector<double>& x,
int y)
const {
693 vector<double> phi(numParameters(), 0.0);
694 if (y != _nClasses - 1) {
695 vector<double>::iterator jt = phi.begin() + y * (2 * _nFeatures + 1);
696 for (vector<double>::const_iterator it = x.begin(); it != x.end(); ++it, ++jt) {
699 for (vector<double>::const_iterator it = x.begin(); it != x.end(); ++it, ++jt) {
700 (*jt) = M_SQRT1_2 * ((*it) * (*it) - 1.0);
709 vector<double> phi(numParameters());
710 vector<double>::iterator jt = phi.begin();
711 for (vector<double>::const_iterator it = x.begin(); it != x.end(); ++it, ++jt) {
714 for (vector<double>::const_iterator it = x.begin(); it != x.end(); ++it, ++jt) {
715 (*jt) = M_SQRT1_2 * ((*it) * (*it) - 1.0);
719 for (
int y = 1; y < _nClasses - 1; y++) {
720 copy(jt - (2 * _nFeatures + 1), jt, jt + 1);
721 jt += (2 * _nFeatures + 1);
727 double dot(
const vector<double>& theta,
const vector<double>& x,
int y)
const {
728 if (y == _nClasses - 1)
return 0.0;
731 vector<double>::const_iterator it = theta.begin() + y * (2 * _nFeatures + 1);
732 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
735 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
736 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
742 return Eigen::Map<const VectorXd>(&theta[y * (2 * _nFeatures + 1)],
743 _nFeatures).dot(Eigen::Map<const VectorXd>(&x[0], _nFeatures)) +
744 Eigen::Map<const VectorXd>(&theta[y * (2 * _nFeatures + 1) + _nFeatures],
745 _nFeatures).dot(M_SQRT1_2 *
746 (Eigen::Map<const VectorXd>(&x[0], x.size()).array().square().array() - 1.0)) +
747 theta[y * (2 * _nFeatures + 1) + 2 * _nFeatures];
752 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
754 vector<double>::const_iterator it = theta.begin();
755 for (
int y = 0; y < _nClasses - 1; y++) {
756 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
759 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
760 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
768 void mac(vector<double>& theta,
const vector<double>& x,
double alpha,
int y)
const {
769 if (y == _nClasses - 1)
return;
770 vector<double>::iterator it = theta.begin() + y * (2 * _nFeatures + 1);
771 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
772 (*it) += alpha * (*ix);
774 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
775 (*it) += M_SQRT1_2 * alpha * ((*ix) * (*ix) - 1.0);
781 void mac(vector<double>& theta,
const vector<double>& x,
const vector<double>& alpha)
const {
782 vector<double>::iterator it = theta.begin();
783 for (
int y = 0; y < _nClasses - 1; y++) {
785 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
786 (*it) += alpha[y] * (*ix);
788 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
789 (*it) += M_SQRT1_2 * alpha[y] * ((*ix) * (*ix) - 1.0);
793 Eigen::Map<VectorXd>(&theta[y * (2 * _nFeatures + 1)], _nFeatures) += alpha[y] *
794 Eigen::Map<const VectorXd>(&x[0], x.size());
795 Eigen::Map<VectorXd>(&theta[y * (2 * _nFeatures + 1) + _nFeatures], _nFeatures) += M_SQRT1_2 * alpha[y] *
796 (Eigen::Map<const VectorXd>(&x[0], x.size()).array().square().array() - 1.0);
797 theta[y * (2 * _nFeatures + 1) + 2 * _nFeatures] += alpha[y];
814 const char *
type ()
const {
return "drwnQuadraticJointFeatureMap"; }
818 int numParameters()
const {
return std::max(((_nFeatures + 3) * _nFeatures / 2 + 1) *
819 (_nClasses - 1), 0); }
822 vector<double>
operator()(
const vector<double>& x,
int y)
const {
823 vector<double> phi(numParameters(), 0.0);
824 if (y != _nClasses - 1) {
825 vector<double>::iterator it = phi.begin() + y * ((_nFeatures + 3) * _nFeatures / 2 + 1);
826 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
829 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
830 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
831 (*it) = (*ix) * (*jx);
833 (*it) = M_SQRT1_2 * ((*ix) * (*ix) - 1.0);
842 vector<double> phi(numParameters());
843 vector<double>::iterator it = phi.begin();
844 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
847 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
848 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
849 (*it) = (*ix) * (*jx);
851 (*it) = M_SQRT1_2 * ((*ix) * (*ix) - 1.0);
855 vector<double>::iterator jt = ++it;
856 while (jt != phi.end()) {
857 copy(phi.begin(), it, jt);
858 jt += it - phi.begin();
864 double dot(
const vector<double>& theta,
const vector<double>& x,
int y)
const {
865 if (y == _nClasses - 1)
return 0.0;
867 vector<double>::const_iterator it = theta.begin() +
868 y * ((_nFeatures + 3) * _nFeatures / 2 + 1);
869 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
872 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
873 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
874 v += (*it) * (*ix) * (*jx);
876 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
884 double dot(
const vector<double>& theta,
const vector<double>& x)
const {
886 vector<double>::const_iterator it = theta.begin();
887 for (
int y = 0; y < _nClasses - 1; y++) {
888 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
891 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
892 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
893 v += (*it) * (*ix) * (*jx);
895 v += M_SQRT1_2 * (*it) * ((*ix) * (*ix) - 1.0);
903 void mac(vector<double>& theta,
const vector<double>& x,
double alpha,
int y)
const {
904 if (y == _nClasses - 1)
return;
905 vector<double>::iterator it = theta.begin() + y * ((_nFeatures + 3) * _nFeatures / 2 + 1);
906 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
907 (*it) += alpha * (*ix);
909 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
910 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
911 (*it) += alpha * (*ix) * (*jx);
913 (*it) += M_SQRT1_2 * alpha * ((*ix) * (*ix) - 1.0);
919 void mac(vector<double>& theta,
const vector<double>& x,
const vector<double>& alpha)
const {
920 vector<double>::iterator it = theta.begin();
921 for (
int y = 0; y < _nClasses - 1; y++) {
922 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
923 (*it) += alpha[y] * (*ix);
925 for (vector<double>::const_iterator ix = x.begin(); ix != x.end(); ++ix, ++it) {
926 for (vector<double>::const_iterator jx = x.begin(); jx != ix; ++jx, ++it) {
927 (*it) += alpha[y] * (*ix) * (*jx);
929 (*it) += M_SQRT1_2 * alpha[y] * ((*ix) * (*ix) - 1.0);
int _nFeatures
number of input features
Definition: drwnFeatureMaps.h:42
void mac(vector< double > &theta, const vector< double > &x, const vector< double > &alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:497
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:245
drwnJointFeatureMap()
default constructor
Definition: drwnFeatureMaps.h:300
drwnFeatureMap()
default constructor
Definition: drwnFeatureMaps.h:46
double dot(const vector< double > &theta, const vector< double > &x) const
returns the dot product (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:347
int numClasses() const
returns the number of classes
Definition: drwnFeatureMaps.h:312
vector< double > operator()(const vector< double > &x) const
feature vector summed over y
Definition: drwnFeatureMaps.h:841
vector< double > operator()(const vector< double > &x) const
feature vector
Definition: drwnFeatureMaps.h:230
vector< double > operator()(const vector< double > &x, int y) const
feature vector for given y
Definition: drwnFeatureMaps.h:552
int numParameters() const
returns the number of features in the output space
Definition: drwnFeatureMaps.h:134
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:752
int numParameters() const
returns the number of features in the (joint) output space
Definition: drwnFeatureMaps.h:540
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:404
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:597
void mac(vector< double > &theta, const vector< double > &x, double alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:202
interface for an object that returns its own type as a string
Definition: drwnInterfaces.h:25
drwnIdentityFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:97
int numParameters() const
returns the number of features in the (joint) output space
Definition: drwnFeatureMaps.h:408
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:130
Defines the interface for a joint feature mapping .
Definition: drwnFeatureMaps.h:293
void mac(vector< double > &theta, const vector< double > &x, double alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:114
void mac(vector< double > &theta, const vector< double > &x, double alpha, int y) const
multiply-accumulate
Definition: drwnFeatureMaps.h:903
virtual void mac(vector< double > &theta, const vector< double > &x, double alpha, int y) const
provides multiply-accumulate operation (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:356
void mac(vector< double > &theta, const vector< double > &x, const vector< double > &alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:919
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:676
drwnQuadraticFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:224
void mac(vector< double > &theta, const vector< double > &x, double alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:152
virtual void mac(vector< double > &theta, const vector< double > &x, const vector< double > &alpha) const
provides multiply-accumulate operation (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:364
virtual vector< double > operator()(const vector< double > &x) const
returns (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:325
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:814
virtual double dot(const vector< double > &theta, const vector< double > &x, int y) const
returns the dot product (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:337
void mac(vector< double > &theta, const vector< double > &x, double alpha, int y) const
multiply-accumulate
Definition: drwnFeatureMaps.h:610
Same as drwnSquareJointFeatureMap but adds cross-terms.
Definition: drwnFeatureMaps.h:806
int numFeatures() const
returns the number of features in the input space
Definition: drwnFeatureMaps.h:310
Same as drwnIdentityJointFeatureMap but adds a square term for each feature i.e., ...
Definition: drwnFeatureMaps.h:652
Includes a copy of each feature from the input space for each class other than the last...
Definition: drwnFeatureMaps.h:380
vector< double > operator()(const vector< double > &x) const
feature vector summed over y
Definition: drwnFeatureMaps.h:562
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:884
int numParameters() const
returns the number of features in the (joint) output space
Definition: drwnFeatureMaps.h:818
interface for cloning object (i.e., virtual copy constructor)
Definition: drwnInterfaces.h:36
virtual void initialize(int nFeatures, int nClasses)
initialize number of classes and number of features
Definition: drwnFeatureMaps.h:317
vector< double > operator()(const vector< double > &x) const
feature vector
Definition: drwnFeatureMaps.h:178
vector< double > operator()(const vector< double > &x, int y) const
feature vector for given y
Definition: drwnFeatureMaps.h:692
drwnIdentityJointFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:405
double dot(const vector< double > &theta, const vector< double > &x, int y) const
dot product
Definition: drwnFeatureMaps.h:727
Augments input feature vector with square of each feature (normalized so that if input is zero mean a...
Definition: drwnFeatureMaps.h:216
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:461
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:189
drwnFeatureMap(int nFeatures)
construct with known number of input features
Definition: drwnFeatureMaps.h:48
double dot(const vector< double > &theta, const vector< double > &x, int y) const
dot product
Definition: drwnFeatureMaps.h:573
virtual void initialize(int nFeatures)
initialize number of (intput) features
Definition: drwnFeatureMaps.h:60
vector< double > operator()(const vector< double > &x, int y) const
joint feature vector for given class
Definition: drwnFeatureMaps.h:420
drwnBiasFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:131
drwnBiasJointFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:537
vector< double > operator()(const vector< double > &x, int y) const
feature vector for given y
Definition: drwnFeatureMaps.h:822
Augments input feature vector with square of each feature (normalized so that if input is zero mean a...
Definition: drwnFeatureMaps.h:164
virtual void mac(vector< double > &theta, const vector< double > &x, double alpha) const
provides multiply-accumulate operation (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:78
double dot(const vector< double > &theta, const vector< double > &x, int y) const
dot product
Definition: drwnFeatureMaps.h:438
void mac(vector< double > &theta, const vector< double > &x, double alpha, int y) const
multiply-accumulate
Definition: drwnFeatureMaps.h:473
int numParameters() const
returns the number of features in the output space
Definition: drwnFeatureMaps.h:175
void mac(vector< double > &theta, const vector< double > &x, double alpha, int y) const
multiply-accumulate
Definition: drwnFeatureMaps.h:768
void mac(vector< double > &theta, const vector< double > &x, double alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:261
void mac(vector< double > &theta, const vector< double > &x, const vector< double > &alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:635
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:171
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:223
virtual double dot(const vector< double > &theta, const vector< double > &x) const
returns the dot product (default behaviour is very inefficient)
Definition: drwnFeatureMaps.h:68
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:536
int _nClasses
number of class labels
Definition: drwnFeatureMaps.h:296
Augments input feature vector with 1 (i.e., to allow for a bias weight)
Definition: drwnFeatureMaps.h:123
int numParameters() const
returns the number of features in the (joint) output space
Definition: drwnFeatureMaps.h:680
double dot(const vector< double > &theta, const vector< double > &x, int y) const
dot product
Definition: drwnFeatureMaps.h:864
vector< double > operator()(const vector< double > &x) const
feature vector
Definition: drwnFeatureMaps.h:137
Copies input feature space to output feature space.
Definition: drwnFeatureMaps.h:89
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:145
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFeatureMaps.h:96
int numFeatures() const
returns the number of features in the input space
Definition: drwnFeatureMaps.h:55
drwnQuadraticJointFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:815
Same as drwnIdentityJointFeatureMap but adds a bias term for each class i.e., .
Definition: drwnFeatureMaps.h:512
drwnSquareFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:172
vector< double > operator()(const vector< double > &x) const
feature vector
Definition: drwnFeatureMaps.h:103
void mac(vector< double > &theta, const vector< double > &x, const vector< double > &alpha) const
multiply-accumulate
Definition: drwnFeatureMaps.h:781
int _nFeatures
number of input features
Definition: drwnFeatureMaps.h:295
virtual ~drwnFeatureMap()
destructor
Definition: drwnFeatureMaps.h:50
int numParameters() const
returns the number of features in the output space
Definition: drwnFeatureMaps.h:100
Defines the interface for a feature mapping .
Definition: drwnFeatureMaps.h:40
virtual ~drwnJointFeatureMap()
destructor
Definition: drwnFeatureMaps.h:305
drwnSquareJointFeatureMap * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFeatureMaps.h:677
double dot(const vector< double > &theta, const vector< double > &x) const
dot product
Definition: drwnFeatureMaps.h:108
vector< double > operator()(const vector< double > &x) const
joint feature vector summed over classes
Definition: drwnFeatureMaps.h:429
drwnJointFeatureMap(int nFeatures, int nClasses)
construct with known number of input features and classes
Definition: drwnFeatureMaps.h:302
vector< double > operator()(const vector< double > &x) const
feature vector summed over y
Definition: drwnFeatureMaps.h:708
int numParameters() const
returns the number of features in the output space
Definition: drwnFeatureMaps.h:227