SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2012 Fernando José Iglesias García 00008 * Copyright (C) 2012 Fernando José Iglesias García 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/SequenceLabels.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 00090 virtual void reshape_emission_params(CDynamicObjectArray* plif_matrix, 00091 SGVector< float64_t > w, int32_t num_feats, int32_t num_plif_nodes) = 0; 00092 00101 virtual void reshape_transmission_params( 00102 SGMatrix< float64_t >& transmission_weights, 00103 SGVector< float64_t > w) = 0; 00104 00111 virtual SGVector< int32_t > labels_to_states(CSequence* label_seq) const = 0; 00112 00119 virtual CSequence* states_to_labels(SGVector< int32_t > state_seq) const = 0; 00120 00133 virtual void weights_to_vector(SGVector< float64_t >& psi, 00134 SGMatrix< float64_t > transmission_weights, 00135 SGVector< float64_t > emission_weights, 00136 int32_t num_feats, int32_t num_obs) const = 0; 00137 00150 virtual SGVector< float64_t > weights_to_vector(SGMatrix< float64_t > transmission_weights, 00151 SGVector< float64_t > emission_weights, int32_t num_feats, int32_t num_obs) const = 0; 00152 00171 virtual SGVector< int32_t > get_monotonicity(int32_t num_free_states, 00172 int32_t num_feats) const; 00173 00189 SGVector< float64_t > get_start_states() const; 00190 00206 SGVector< float64_t > get_stop_states() const; 00207 00209 virtual const char* get_name() const { return "StateModel"; } 00210 00211 private: 00213 void init(); 00214 00215 protected: 00217 int32_t m_num_states; 00218 00220 int32_t m_num_transmission_params; 00221 00223 SGMatrix< float64_t > m_state_loss_mat; 00224 00226 SGVector< float64_t > m_p; 00227 00229 SGVector< float64_t > m_q; 00230 00231 }; /* class CStateModel */ 00232 00233 } /* namespace shogun */ 00234 00235 #endif /* __STATE_MODEL_H__ */