SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MultitaskKernelMklNormalizer.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2010 Christian Widmer
8  * Copyright (C) 2010 Max-Planck-Society
9  */
10 
11 #ifndef _MULTITASKKERNELMKLNORMALIZER_H___
12 #define _MULTITASKKERNELMKLNORMALIZER_H___
13 
16 #include <shogun/kernel/Kernel.h>
17 #include <algorithm>
18 #include <string>
19 
20 namespace shogun
21 {
22 
23 
28 {
29 
30 public:
31 
35  {
37  }
38 
39 
42  virtual bool init(CKernel* k)
43  {
44 
45  //same as first-element normalizer
46  CFeatures* old_lhs=k->lhs;
47  CFeatures* old_rhs=k->rhs;
48  k->lhs=old_lhs;
49  k->rhs=old_lhs;
50 
51  if (std::string(k->get_name()) == "WeightedDegree") {
52  SG_INFO("using first-element normalization\n");
53  scale=k->compute(0, 0);
54  } else {
55  SG_INFO("no inner normalization for non-WDK kernel\n");
56  scale=1.0;
57  }
58 
59 
60  k->lhs=old_lhs;
61  k->rhs=old_rhs;
62 
63  ASSERT(k);
64  int32_t num_lhs = k->get_num_vec_lhs();
65  int32_t num_rhs = k->get_num_vec_rhs();
66  ASSERT(num_lhs>0);
67  ASSERT(num_rhs>0);
68 
69 
70  return true;
71  }
72 
73 
74 
79  inline virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
80  {
81  SG_ERROR("normalize_lhs not implemented");
82  return 0;
83  }
84 
89  inline virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
90  {
91  SG_ERROR("normalize_rhs not implemented");
92  return 0;
93  }
94 
95 public:
96 
97 
101  virtual float64_t get_beta(int32_t idx) = 0;
102 
107  virtual void set_beta(int32_t idx, float64_t weight) = 0;
108 
109 
113  virtual int32_t get_num_betas() = 0;
114 
115 
117  inline virtual const char* get_name() const
118  {
119  return "MultitaskKernelMklNormalizer";
120  }
121 
122 protected:
123 
124 
127 
128 };
129 }
130 #endif

SHOGUN Machine Learning Toolbox - Documentation