regevs / factorial_hmm Goto Github PK
View Code? Open in Web Editor NEWFactorialHMM, a Python package for fast exact inference in Factorial Hidden Markov Models
License: GNU General Public License v2.0
FactorialHMM, a Python package for fast exact inference in Factorial Hidden Markov Models
License: GNU General Public License v2.0
I would be nice to have the EM
method of FullDiscreteFactorialHMM
also support multiple sequences of observed states.
For instance, the fit
method of hmmlearn
allows parameters estimation from multiple sequences for basic (i.e., non-factorial) HMMs (see https://github.com/hmmlearn/hmmlearn/blob/master/lib/hmmlearn/base.py#L440-L488).
This probably requires to split MStep
in two parts: the former (equivalent of hmmlearn's _accumulate_sufficient_statistics
) will collect statistics about the parameters and will need to be called on every sequence of observed states; the latter (equivalent of hmmlearn's _do_mstep
) will be required to normalize the parameters and will need to be called only once per iteration.
I'm having trouble following the logic of the MultiplyTransitionMatrixVector
function and I have thusfar been unable to get this function to work as demonstrated by the simple example below... Any guidance would be greatly appreciated -- thanks!
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from factorial_hmm_test import *
In [2]: from factorial_hmm import *
In [3]: model = ExampleFullDiscreteFactorialHMM(11)
In [4]: model.GetTransitionMatrix(0) @ np.random.randn(16)
Out[4]:
array([-0.0381503 , 0.08041185, -0.07615602, 0.4513467 , -0.06822525,
0.02532833, -0.37132319, 0.41988943, -0.06897605, -0.00527082,
-0.16544137, 0.1655481 , -0.0785179 , -0.04276934, -0.54833598,
0.15224777])
In [5]: model.MultiplyTransitionMatrixVector(0, np.random.randn(16))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-1777e0d59086> in <module>
----> 1 model.MultiplyTransitionMatrixVector(0, np.random.randn(16))
~/code/factorial_hmm/factorial_hmm.py in MultiplyTransitionMatrixVector(self, n_step, vector, transpose)
74 vector,
75 self.idx_in,
---> 76 self.idx_out[i],
77 )
78
<__array_function__ internals> in einsum(*args, **kwargs)
~/anaconda3/lib/python3.7/site-packages/numpy/core/einsumfunc.py in einsum(*operands, **kwargs)
1354 # If no optimization, run pure einsum
1355 if optimize_arg is False:
-> 1356 return c_einsum(*operands, **kwargs)
1357
1358 valid_einsum_kwargs = ['out', 'dtype', 'order', 'casting']
ValueError: einstein sum subscripts string contains too many subscripts for operand 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.