Skip to content

Commit

Permalink
AR Emissions: Fix initialization to be stable.
Browse files Browse the repository at this point in the history
Addresses Issue #75
  • Loading branch information
bantin committed Dec 13, 2019
1 parent 0d6aa48 commit f66316c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ssm/emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ def smooth(self, expected_states, variational_mean, data, input=None, mask=None,


class AutoRegressiveEmissions(_AutoRegressiveEmissionsMixin, _LinearEmissions):
def __init__(self, N, K, D, M=0, single_subspace=True, **kwargs):
super(AutoRegressiveEmissions, self).__init__(N, K, D, M=M, single_subspace=single_subspace, **kwargs)
# Shrink the eigenvalues of the A matrices to avoid instability.
# Since the As are diagonal, this is just a clip.
self.As = np.clip(self.As, -1.0 + 1e-8, 1 - 1e-8)

@ensure_args_are_lists
def initialize(self, datas, inputs=None, masks=None, tags=None, num_em_iters=25):
# Initialize the subspace with PCA
Expand Down

0 comments on commit f66316c

Please sign in to comment.