Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __STATE_MODEL_H__
00012 #define __STATE_MODEL_H__
00013
00014 #include <shogun/base/SGObject.h>
00015 #include <shogun/lib/SGMatrix.h>
00016 #include <shogun/lib/SGVector.h>
00017 #include <shogun/mathematics/Math.h>
00018 #include <shogun/structure/HMSVMLabels.h>
00019 #include <shogun/structure/StateModelTypes.h>
00020
00021 namespace shogun
00022 {
00023
00028 class CStateModel : public CSGObject
00029 {
00030 public:
00032 CStateModel();
00033
00035 virtual ~CStateModel();
00036
00038 int32_t get_num_states() const;
00039
00041 int32_t get_num_transmission_params() const;
00042
00053 virtual SGMatrix< float64_t > loss_matrix(CSequence* label_seq) = 0;
00054
00064 virtual float64_t loss(CSequence* label_seq_lhs, CSequence* label_seq_rhs) = 0;
00065
00077 virtual void reshape_emission_params(SGVector< float64_t >& emission_weights,
00078 SGVector< float64_t > w, int32_t num_feats, int32_t num_obs) = 0;
00079
00088 virtual void reshape_transmission_params(
00089 SGMatrix< float64_t >& transmission_weights,
00090 SGVector< float64_t > w) = 0;
00091
00098 virtual SGVector< int32_t > labels_to_states(CSequence* label_seq) const = 0;
00099
00106 virtual CSequence* states_to_labels(SGVector< int32_t > state_seq) const = 0;
00107
00121 virtual void weights_to_vector(SGVector< float64_t >& psi,
00122 SGMatrix< float64_t > transmission_weights,
00123 SGVector< float64_t > emission_weights,
00124 int32_t num_feats, int32_t num_obs) const = 0;
00125
00144 virtual SGVector< int32_t > get_monotonicity(int32_t num_free_states,
00145 int32_t num_feats) const;
00146
00162 SGVector< float64_t > get_start_states() const;
00163
00179 SGVector< float64_t > get_stop_states() const;
00180
00182 virtual const char* get_name() const { return "StateModel"; }
00183
00184 private:
00186 void init();
00187
00188 protected:
00190 int32_t m_num_states;
00191
00193 int32_t m_num_transmission_params;
00194
00196 SGMatrix< float64_t > m_state_loss_mat;
00197
00199 SGVector< float64_t > m_p;
00200
00202 SGVector< float64_t > m_q;
00203
00204 };
00205
00206 }
00207
00208 #endif