SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
14 #include <shogun/lib/config.h>
15 
17 #include <shogun/kernel/Kernel.h>
18 #include <algorithm>
19 #include <string>
20 
21 namespace shogun
22 {
23 
24 
29 {
30 
31 public:
32 
36  {
38  }
39 
40 
43  virtual bool init(CKernel* k)
44  {
45 
46  //same as first-element normalizer
47  CFeatures* old_lhs=k->lhs;
48  CFeatures* old_rhs=k->rhs;
49  k->lhs=old_lhs;
50  k->rhs=old_lhs;
51 
52  if (std::string(k->get_name()) == "WeightedDegree") {
53  SG_INFO("using first-element normalization\n")
54  scale=k->compute(0, 0);
55  } else {
56  SG_INFO("no inner normalization for non-WDK kernel\n")
57  scale=1.0;
58  }
59 
60 
61  k->lhs=old_lhs;
62  k->rhs=old_rhs;
63 
64  ASSERT(k)
65  int32_t num_lhs = k->get_num_vec_lhs();
66  int32_t num_rhs = k->get_num_vec_rhs();
67  ASSERT(num_lhs>0)
68  ASSERT(num_rhs>0)
69 
70 
71  return true;
72  }
73 
74 
75 
80  virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
81  {
82  SG_ERROR("normalize_lhs not implemented")
83  return 0;
84  }
85 
90  virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
91  {
92  SG_ERROR("normalize_rhs not implemented")
93  return 0;
94  }
95 
96 public:
97 
98 
102  virtual float64_t get_beta(int32_t idx) = 0;
103 
108  virtual void set_beta(int32_t idx, float64_t weight) = 0;
109 
110 
114  virtual int32_t get_num_betas() = 0;
115 
116 
118  virtual const char* get_name() const
119  {
120  return "MultitaskKernelMklNormalizer";
121  }
122 
123 protected:
124 
125 
128 
129 };
130 }
131 #endif

SHOGUN Machine Learning Toolbox - Documentation