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

Merge ParticleSampler and HMCSampler into Sampler? #174

Closed
yebai opened this issue Apr 18, 2017 · 6 comments
Closed

Merge ParticleSampler and HMCSampler into Sampler? #174

yebai opened this issue Apr 18, 2017 · 6 comments
Assignees

Comments

@yebai
Copy link
Member

yebai commented Apr 18, 2017

After introducing VarInfo and the new compiler interface, it seems possible to merge some sampler classes into a single one, e.g.

type Sampler{T:<InferenceAlgorithm}
  alg            ::  T
  particles   ::  ParticleContainer
  samples   ::  Array{Sample}     
  info        :: Dict{Symbol,Any} # Stores other sampler data, e.g. chunksize in HMC.          
end

In addition, to query sampler specific information (e.g. gradient sampler, particle sampler), we might consider introduce the following generic APIs for sampler

require_gradient(s :: Sampler) = false
require_particles(s :: Sampler) = false


# Then for HMC, we redefine these functions
require_gradient(s :: Sampler{HMC}) = true

# PG, SMC, IS
require_particles(s :: Sampler{PG}) = true
require_particles(s :: Sampler{SMC}) = true
require_particles(s :: Sampler{IS}) = true
@xukai92
Copy link
Member

xukai92 commented Apr 18, 2017

This makes sense. I'm also thinking the new sampler should somehow make it easier for different samplers to share some basic functions like assume(), rand(), etc. instead of using Union{}

@xukai92
Copy link
Member

xukai92 commented Apr 18, 2017

This data dict would also be helpful for adaptive samplers as we need to pass/store adaptive parameters somehow.

@yebai
Copy link
Member Author

yebai commented Apr 19, 2017

We should consider store run time information in sampler.info as well, e.g. acceptance ratio, time per MCMC iteration, time per leapfrog iteration etc.

@xukai92 xukai92 mentioned this issue Apr 20, 2017
3 tasks
@xukai92
Copy link
Member

xukai92 commented Apr 21, 2017

I think it's bit weird that all samplers should have a filed of particles :: ParticleContainer. I think we should treat it same as VarInfo. Do you think we can remove this field? I briefly looked into PG and SMC codes and feel it should be OK.

xukai92 added a commit that referenced this issue Apr 21, 2017
@xukai92
Copy link
Member

xukai92 commented Apr 21, 2017

@yebai I'm sorry that I pushed my commits (for this issue) directly to the master by mistake. Can you have a look at them?

@yebai
Copy link
Member Author

yebai commented Apr 21, 2017

It's OK. I will take a look and comment on the master branch.

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