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

Sigma calculation error: AttributeError: 'float' object has no attribute 'item' #22

Open
augeorge opened this issue Oct 17, 2022 · 1 comment

Comments

@augeorge
Copy link

Hello I have been using the pococmc package to sample parameters of an ODE-based system. Occasionally, an error arises in my runs: AttributeError: 'float' object has no attribute 'item'. This happens at different times depending on which seed I use, and sometimes doesn't happen at all. It seems like sigma is a Tensor object but is somehow incorrectly being typed as a float? Any ideas how to fix this?

Error trace example:

  sampler.run(p_0, ess, gamma, int(n_dim), int(1000*n_dim), progress=True)
  File "/opt/miniconda3/envs/pyPoco/lib/python3.10/site-packages/pocomc/sampler.py", line 405, in run
    self.u, self.x, self.J, self.L, self.P = self._mutate(
  File "/opt/miniconda3/envs/pyPoco/lib/python3.10/site-packages/pocomc/sampler.py", line 532, in _mutate
    results = preconditioned_metropolis(
  File "/opt/miniconda3/envs/pyPoco/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/opt/miniconda3/envs/pyPoco/lib/python3.10/site-packages/pocomc/mcmc.py", line 167, in preconditioned_metropolis
    scale=sigma.item() / (2.38 / np.sqrt(n_dim)),
AttributeError: 'float' object has no attribute 'item'
@DouglasRWalker
Copy link

I am getting the same error, but for me this error raises every time I run pocomc on a particular model system. However, it never once raised that error when I was running on a simpler system. I would be interested in knowing if there has been any work toward addressing this issue in the code?

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

2 participants