This file is indexed.

/usr/include/shogun/latent/LatentModel.h is in libshogun-dev 3.1.1-1.

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
150
151
152
153
154
155
156
157
158
/*
 * 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) 2012 Viktor Gal
 * Copyright (C) 2012 Viktor Gal
 */

#ifndef __LATENTMODEL_H__
#define __LATENTMODEL_H__

#include <shogun/labels/LatentLabels.h>
#include <shogun/features/LatentFeatures.h>
#include <shogun/features/DotFeatures.h>
#include <shogun/features/DenseFeatures.h>

namespace shogun
{
	/** @brief Abstract class CLatentModel
	 * It represents the application specific model and contains most of the
	 * application dependent logic to solve latent variable based problems.
	 *
	 * The idea is that the user have to define and implement her own model, which
	 * is derived from CLatentModel and implement all the pure virtual functions
	 * which depends on the given problem she wants to solve, like the combined
	 * feature representation: \f$\Psi(\bold{x_i},\bold{h_i})\f$ and the inference
	 * of the latent variable \f$argmax_{h} \langle \bold{w},\Psi(\bold{x},\bold{h}) \rangle\f$
	 */
	class CLatentModel: public CSGObject
	{
		public:
			/** default ctor */
			CLatentModel();

			/** constructor
			 *
			 * @param feats Latent features
			 * @param labels Latent labels
			 * @param do_caching whether caching of PSI vectors is enabled or not. Enabled by default.
			 */
			CLatentModel(CLatentFeatures* feats, CLatentLabels* labels, bool do_caching = true);

			/** destructor */
			virtual ~CLatentModel();

			/** get the number of examples
			 *
			 * @return number of examples/vectors in latent features
			 */
			virtual int32_t get_num_vectors() const;

			/** get the dimension of the combined features, i.e \f$\Psi(\ldots)\f$
			 *
			 * @return dimension of features, i.e. psi vector
			 */
			virtual int32_t get_dim() const=0;

			/** set latent labels
			 *
			 * @param labs latent labels
			 */
			void set_labels(CLatentLabels* labs);

			/** get latent labels
			 *
			 * @return latent labels
			 */
			CLatentLabels* get_labels() const;

			/** set latent features
			 *
			 * @param feats the latent features of the problem
			 */
			void set_features(CLatentFeatures* feats);

			/** get latent features
			 *
			 * @return latent features
			 */
			CLatentFeatures* get_features() const;

			/** Calculate the PSI vectors for all features
			 *
			 * @return PSI vectors
			 */
			virtual CDotFeatures* get_psi_feature_vectors()=0;

			/** User defined \f$h^{*} = argmax_{h} \langle \bold{w},\Psi(\bold{x},\bold{h}) \rangle\f$
			 * This function has to be defined the user as it is applications specific, since
			 * it depends on the user defined latent feature and latent label.
			 *
			 * @param w weight vector
			 * @param idx index of the example
			 * @return returns \f$h^{*}\f$ for the given example
			 */
			virtual CData* infer_latent_variable(const SGVector<float64_t>& w, index_t idx)=0;

			/** Calculates \f$argmax_{h} \langle \bold{w},\Psi(\bold{x},\bold{h}) \rangle\f$
			 * The default implementaiton calculates the argmax_h only on the positive examples.
			 *
			 * @param w weight vector (cutting plane) supplied by the underlying optimizer.
			 */
			virtual void argmax_h(const SGVector<float64_t>& w);

			/** cache the PSI vectors
			 *
			 */
			void cache_psi_features();

			/** get the cached PSI vectors
			 *
			 * @return the cached PSI vectors
			 */
			CDotFeatures* get_cached_psi_features() const;

			/** get caching
			 *
			 * @return true if caching of PSI vectors is enabled; false otherwise
			 */
			inline bool get_caching() const
			{
				return m_do_caching;
			}

			/** set caching of PSI features
			 *
			 * @param caching true if one wants to cache PSI vectors; false otherwise
			 */
			inline void set_caching(bool caching)
			{
				m_do_caching = caching;
			}

			/** Returns the name of the SGSerializable instance.
			 *
			 * @return name of the SGSerializable
			 */
			virtual const char* get_name() const { return "LatentModel"; }

		protected:
			/** latent features for training */
			CLatentFeatures* m_features;
			/** corresponding labels for the train set */
			CLatentLabels* m_labels;
			/** boolean that indicates whether caching of PSI vectors is enabled or not */
			bool m_do_caching;
			/** cached PSI feature vectors after argmax_h */
			CDotFeatures* m_cached_psi;

		private:
			/** register the parameters */
			void register_parameters();
	};
}

#endif /* __LATENTMODEL_H__ */