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

Robust setting of initial point #487

Open
nabriis opened this issue Aug 26, 2024 · 0 comments
Open

Robust setting of initial point #487

nabriis opened this issue Aug 26, 2024 · 0 comments

Comments

@nabriis
Copy link
Collaborator

nabriis commented Aug 26, 2024

          I just want to add a tiny comment that is not very relevant to this PR: initial point will be set to a `np.array` type if not specified, through [_get_default_initial_point](https://github.com/CUQI-DTU/CUQIpy/blob/4a07108f2bb3505dfa8b5db2a8b7ba1a1fde766d/cuqi/experimental/mcmc/_sampler.py#L389C1-L391C28); if specified, it will be set to whatever the user gives, a scalar in this case. I wonder if we should add something to check if the user specified initial point is compatible and possibly convert it to a uniform format, like `np.array`. 

A somehow related scenario, with the current test case, if we set the initial point of x to be a list, list(0.5*np.ones(10)), it will lead to an error:

File ~/CUQIpy/cuqi/experimental/mcmc/_gibbs.py:156, in HybridGibbs.sample(self, Ns)
    154 """ Sample from the joint distribution using Gibbs sampling """
    155 for _ in progressbar(range(Ns)):
--> 156     self.step()
    157     self._store_samples()

File ~/CUQIpy/cuqi/experimental/mcmc/_gibbs.py:206, in HybridGibbs.step(self)
    203     sampler.step()
    205 # Extract samples (Ensure even 1-dimensional samples are 1D arrays)
--> 206 self.current_samples[par_name] = sampler.current_point.reshape(-1)

AttributeError: 'list' object has no attribute 'reshape'

Originally posted by @chaozg in #484 (comment)

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
@nabriis and others