From f66316c2bb2985fefe7f64ab0ec9ab1f90b116bb Mon Sep 17 00:00:00 2001 From: Benjamin Antin Date: Fri, 13 Dec 2019 10:42:57 -0800 Subject: [PATCH] AR Emissions: Fix initialization to be stable. Addresses Issue #75 --- ssm/emissions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ssm/emissions.py b/ssm/emissions.py index 56077004..c5f8b6c5 100644 --- a/ssm/emissions.py +++ b/ssm/emissions.py @@ -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