Git Product home page Git Product logo

langevin-dynamics's People

Contributors

alisiahkoohi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

langevin-dynamics's Issues

Questions regarding the code for Metropolis-adjusted Langevin

Hi, thanks for the repo! I have three questions regarding the code for Metropolis-adjusted Langevin:

  1. When a proposal is rejected, why is the gradient not reset (i.e., self.grad[1].data = self.grad[0].data)?

    else:
    self.x[1].data = self.x[0].data
    self.P[1].data = self.P[0].data

  2. When computing the density of the proposal distribution, why isP[1] used for both directions? Shouldn't it be P[idx^1]?

    return (-(.25 / self.lr_fn(self.counter)) *
    (self.x[idx] - self.x[idx ^ 1] -
    self.lr_fn(self.counter) * self.grad[idx ^ 1] / self.P[1]) *
    self.P[1]
    @ (self.x[idx] - self.x[idx ^ 1] -
    self.lr_fn(self.counter) * self.grad[idx ^ 1] / self.P[1]))

  3. Why are the rejected samples discarded? Shouldn't MH keep both accepted and rejected samples in the list?

Didn't zero the gradient in the optimizer

Hi,

Thank you so much for the repository. I am learning MCMC. It's really helpful for me.
I have a question. In class LangevinDynamics(object):, you never run self.optim.zero_grad(). Is this on purpose?

You use the preconditioned SGD in gaussian_LD.py demo. However, if you change pSGLD to SGLD, it actually doesn't work:
image

Direction of the gradient

Thanks for the code! I have a question regarding the gradient's direction when sampling the next variable.

In class pSGLD(Optimizer), the mean is updated using a negative learning rate p.data.addcdiv_(grad, G, value=-group['lr']). However, when calculating the transition probability in def proposal_dist(self, idx: int) -> torch.Tensor from class MetropolisAdjustedLangevin(object), I think the gradient direction needs to be reversed self.x[idx] - self.x[idx ^ 1] + self.lr_fn(self.counter) * self.grad[idx ^ 1] instead ofself.x[idx] - self.x[idx ^ 1] - self.lr_fn(self.counter) * self.grad[idx ^ 1]. Why is the gradient implemented in another direction?

Question regarding the pSDG sampler

Hi,

in line 105 of precondSGLD.py, why are you dividing by G to obtain the noise_std? Surely following the paper by Li et al. you should be multiplying by G? Or am I missing something? Because this line is causing my parameter estimates to explode ...
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.