Skip to content

Commit

Permalink
[patch:lib] Fix strict left-right topology serialization (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
eonu authored May 16, 2020
1 parent 7b10096 commit 97f5c3b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/sequentia/classifiers/hmm/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ def __init__(self, label, n_states, topology='left-right', random_state=None):
n_states, lambda x: x > 0, desc='number of states', expected='greater than zero')
self._val.one_of(topology, ['ergodic', 'left-right', 'strict-left-right'], desc='topology')
self._random_state = self._val.random_state(random_state)
self._topology = {
'ergodic': _ErgodicTopology,
'left-right': _LeftRightTopology,
'strict-left-right': _StrictLeftRightTopology
}[topology](self._n_states, self._random_state)
self._topologies = {'ergodic': _ErgodicTopology, 'left-right': _LeftRightTopology, 'strict-left-right': _StrictLeftRightTopology}
self._topologies.update(dict([reversed(i) for i in self._topologies.items()]))
self._topology = self._topologies[topology](self._n_states, self._random_state)

def set_uniform_initial(self):
"""Sets a uniform initial state distribution."""
Expand Down Expand Up @@ -198,7 +196,7 @@ def as_dict(self):
return {
'label': self._label,
'n_states': self._n_states,
'topology': 'ergodic' if isinstance(self._topology, _ErgodicTopology) else 'left-right',
'topology': self._topologies[self._topology.__class__],
'model': {
'initial': self._initial.tolist(),
'transitions': self._transitions.tolist(),
Expand Down

0 comments on commit 97f5c3b

Please sign in to comment.