/usr/include/shogun/features/FKFeatures.h is in libshogun-dev 1.1.0-4ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 1999-2009 Soeren Sonnenburg
* Written (W) 1999-2008 Gunnar Raetsch
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/
#ifndef _CFKFEATURES__H__
#define _CFKFEATURES__H__
#include <shogun/features/SimpleFeatures.h>
#include <shogun/distributions/HMM.h>
namespace shogun
{
template <class T> class CSimpleFeatures;
class CHMM;
/** @brief The class FKFeatures implements Fischer kernel features obtained from
* two Hidden Markov models.
*
* It was used in
*
* K. Tsuda, M. Kawanabe, G. Raetsch, S. Sonnenburg, and K.R. Mueller. A new
* discriminative kernel from probabilistic models. Neural Computation,
* 14:2397-2414, 2002.
*
* which also has the details.
*
* Note that FK-features are computed on the fly, so to be effective feature
* caching should be enabled.
*
* It inherits its functionality from CSimpleFeatures, which should be
* consulted for further reference.
*/
class CFKFeatures: public CSimpleFeatures<float64_t>
{
public:
/** default constructor */
CFKFeatures();
/** constructor
*
* @param size cache size
* @param p positive HMM
* @param n negative HMM
*/
CFKFeatures(int32_t size, CHMM* p, CHMM* n);
/** copy constructor */
CFKFeatures(const CFKFeatures &orig);
virtual ~CFKFeatures();
/** set HMMs
*
* @param p positive HMM
* @param n negative HMM
*/
void set_models(CHMM* p, CHMM* n);
/** set weight a
*
* @param a weight a
*/
inline void set_a(float64_t a)
{
weight_a=a;
}
/** get weight a
*
* @return weight a
*/
inline float64_t get_a()
{
return weight_a;
}
/** set feature matrix
*
* @return something floaty
*/
virtual float64_t* set_feature_matrix();
/** set opt a
*
* @param a a
* @return something floaty
*/
float64_t set_opt_a(float64_t a=-1);
/** get weight_a
*
* @return weight_a
*/
inline float64_t get_weight_a() { return weight_a; };
/** @return object name */
inline virtual const char* get_name() const { return "FKFeatures"; }
protected:
/** compute feature vector
*
* @param num num
* @param len len
* @param target
* @return something floaty
*/
virtual float64_t* compute_feature_vector(
int32_t num, int32_t& len, float64_t* target=NULL);
/** computes the feature vector to the address addr
*
* @param addr address
* @param num num
* @param len len
*/
void compute_feature_vector(float64_t* addr, int32_t num, int32_t& len);
/** deriv a
*
* @param a a
* @param dimension dimension
*/
float64_t deriv_a(float64_t a, int32_t dimension=-1) ;
private:
void init();
protected:
/** positive HMM */
CHMM* pos;
/** negative HMM */
CHMM* neg;
/** positive prob */
float64_t* pos_prob;
/** negative prob */
float64_t* neg_prob;
/** weight a */
float64_t weight_a;
};
}
#endif
|