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

sampling with Poisson emissions gives ValueError #74

Closed
bantin opened this issue Dec 12, 2019 · 3 comments
Closed

sampling with Poisson emissions gives ValueError #74

bantin opened this issue Dec 12, 2019 · 3 comments

Comments

@bantin
Copy link
Collaborator

bantin commented Dec 12, 2019

The following lines give a value error most of the time:

true_lds = ssm.LDS(15, 10, dynamics="none", emissions="poisson")
x,y = true_lds.sample(1000)

The traceback looks like this:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-27cbe882d496> in <module>
----> 1 x,y = true_lds.sample(1000)

/Users/bantin/Documents/Linderman-Shenoy/ssm/ssm/lds.py in sample(self, T, input, tag, prefix, with_noise)
   1018
   1019     def sample(self, T, input=None, tag=None, prefix=None, with_noise=True):
-> 1020         (_, x, y) = super().sample(T, input=input, tag=tag, prefix=prefix, with_noise=with_noise)
   1021         return (x, y)

/Users/bantin/Documents/Linderman-Shenoy/ssm/ssm/lds.py in sample(self, T, input, tag, prefix, with_noise)
    252         # Sample observations given latent states
    253         # TODO: sample in the loop above?
--> 254         y = self.emissions.sample(z, x, input=input, tag=tag)
    255         return z[pad:], x[pad:], y[pad:]
    256

/Users/bantin/Documents/Linderman-Shenoy/ssm/ssm/emissions.py in sample(self, z, x, input, tag)
    640         z = np.zeros_like(z, dtype=int) if self.single_subspace else z
    641         lambdas = self.mean(self.forward(x, input, tag))
--> 642         y = npr.poisson(lambdas[np.arange(T), z, :])
    643         return y
    644

~/anaconda3/lib/python3.7/site-packages/autograd/tracer.py in f_wrapped(*args, **kwargs)
     46             return new_box(ans, trace, node)
     47         else:
---> 48             return f_raw(*args, **kwargs)
     49     f_wrapped.fun = f_raw
     50     f_wrapped._is_autograd_primitive = True

mtrand.pyx in numpy.random.mtrand.RandomState.poisson()

common.pyx in numpy.random.common.disc()

common.pyx in numpy.random.common.discrete_broadcast_d()

common.pyx in numpy.random.common.check_array_constraint()

ValueError: lam value too large

I think this means that somewhere the lambda parameter passed to npr.Poisson is too large. According to the documentation, "Because the output is limited to the range of the C long type, a ValueError is raised when lam is within 10 sigma of the maximum representable value."

I don't think this is a big issue per se -- it's just because the forward function generating the lambdas is unstable. But maybe the default initializations could be adjusted so that this doesn't happen.

@bantin
Copy link
Collaborator Author

bantin commented Dec 13, 2019

Possible fix in 0d6aa48. Will close once merged.

@bantin
Copy link
Collaborator Author

bantin commented Dec 18, 2019

• Also should switch default link to softplus

@bantin
Copy link
Collaborator Author

bantin commented Dec 19, 2019

Switched default link to softplus in f363c8a

@bantin bantin closed this as completed Dec 20, 2019
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