Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Identity Emissions #170

Open
YUJINHAN93 opened this issue Jan 6, 2025 · 0 comments
Open

Issue with Identity Emissions #170

YUJINHAN93 opened this issue Jan 6, 2025 · 0 comments

Comments

@YUJINHAN93
Copy link

Hi,
This is related to #88 , I think there is still an issue with identity emissions.
When I set emissions="studentst_id" or "gaussian_id", the initialization works fine, but I encounter the error below during model fitting.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-50-77c812f71179> in <module>
      1 q_elbos_lem, q_lem = rslds.fit(y, method="laplace_em",
      2                                variational_posterior="structured_meanfield",
----> 3                                initialize=False, num_iters=100, alpha=0.5)

~/.local/lib/python3.7/site-packages/ssm/util.py in wrapper(self, datas, inputs, masks, tags, **kwargs)
    107             tags = [tags]
    108 
--> 109         return f(self, datas, inputs=inputs, masks=masks, tags=tags, **kwargs)
    110 
    111     return wrapper

~/.local/lib/python3.7/site-packages/ssm/lds.py in fit(self, datas, inputs, masks, tags, method, variational_posterior, initialize, **kwargs)
    853         # Initialize the variational posterior
    854         posterior = self._make_variational_posterior(variational_posterior, datas, inputs, masks, tags, method)
--> 855         elbos = _fitting_methods[method](posterior, datas, inputs, masks, tags, learning=True, **kwargs)
    856         return elbos, posterior
    857 

~/.local/lib/python3.7/site-packages/ssm/lds.py in _fit_laplace_em(self, variational_posterior, datas, inputs, masks, tags, num_iters, num_samples, continuous_optimizer, continuous_tolerance, continuous_maxiter, emission_optimizer, emission_optimizer_maxiter, parameters_update, alpha, learning)
    730         Assume q(z) is a chain-structured discrete graphical model.
    731         """
--> 732         elbos = [self._laplace_em_elbo(variational_posterior, datas, inputs, masks, tags)]
    733         pbar = trange(num_iters)
    734         pbar.set_description("ELBO: {:.1f}".format(elbos[-1]))

~/.local/lib/python3.7/site-packages/ssm/lds.py in _laplace_em_elbo(self, variational_posterior, datas, inputs, masks, tags)
    699             log_Ps = self.transitions.log_transition_matrices(x, input, x_mask, tag)
    700             log_likes = self.dynamics.log_likelihoods(x, input, x_mask, tag)
--> 701             log_likes += self.emissions.log_likelihoods(data, input, mask, tag, x)
    702 
    703             # Compute the expected log probability

~/.local/lib/python3.7/site-packages/ssm/emissions.py in log_likelihoods(self, data, input, mask, tag, x)
    448     def log_likelihoods(self, data, input, mask, tag, x):
    449         N, etas, nus = self.N, np.exp(self.inv_etas), np.exp(self.inv_nus)
--> 450         mus = self.forward(x, input, tag)
    451 
    452         resid = data[:, None, :] - mus

TypeError: forward() takes 3 positional arguments but 4 were given

I also experience the same error as in #88 under these conditions. I'm not sure why this error keeps happening, given that it was updated in #88 . Does anyone have any ideas?

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-51-b963545280d0> in <module>
      1 q_elbos_lem, q_lem = rslds.fit(y, method="bbvi",
      2                                variational_posterior="meanfield",
----> 3                                initialize=False, num_iters=100, alpha=0.5)

~/.local/lib/python3.7/site-packages/ssm/util.py in wrapper(self, datas, inputs, masks, tags, **kwargs)
    107             tags = [tags]
    108 
--> 109         return f(self, datas, inputs=inputs, masks=masks, tags=tags, **kwargs)
    110 
    111     return wrapper

~/.local/lib/python3.7/site-packages/ssm/lds.py in fit(self, datas, inputs, masks, tags, method, variational_posterior, initialize, **kwargs)
    853         # Initialize the variational posterior
    854         posterior = self._make_variational_posterior(variational_posterior, datas, inputs, masks, tags, method)
--> 855         elbos = _fitting_methods[method](posterior, datas, inputs, masks, tags, learning=True, **kwargs)
    856         return elbos, posterior
    857 

~/.local/lib/python3.7/site-packages/ssm/lds.py in _fit_svi(self, variational_posterior, datas, inputs, masks, tags, learning, optimizer, num_iters, **kwargs)
    414         # Initialize the parameters
    415         if learning:
--> 416             params = (self.params, variational_posterior.params)
    417         else:
    418             params = variational_posterior.params

~/.local/lib/python3.7/site-packages/ssm/lds.py in params(self)
    157                self.transitions.params, \
    158                self.dynamics.params, \
--> 159                self.emissions.params
    160 
    161     @params.setter

~/.local/lib/python3.7/site-packages/ssm/emissions.py in params(self)
    434     @property
    435     def params(self):
--> 436         return super(_StudentsTEmissionsMixin, self).params + (self.inv_etas, self.inv_nus)
    437 
    438     @params.setter

~/.local/lib/python3.7/site-packages/ssm/emissions.py in params(self)
     20     @property
     21     def params(self):
---> 22         raise NotImplementedError
     23 
     24     @params.setter

NotImplementedError: 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant