Skip to content

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

@augeorge

Description

@augeorge

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions