Code Monkey home page Code Monkey logo

Comments (6)

fredo-dedup avatar fredo-dedup commented on June 2, 2024

Hi
I reread the code in SerialMC.jl and apparently we don't store the log posterior in the diagnostics field (even though the samplers apparently return them).

I'll see if I can add that... (no delay promises ! ).

from klara.jl.

papamarkou avatar papamarkou commented on June 2, 2024

I think it is better to store and return the absolute minimum in order to avoid excessive storage requirements for the output. It is easy to evaluate the log-posterior using the returned chain if desired. I will write up a simple example to clarify how the user can achieve this.

from klara.jl.

papamarkou avatar papamarkou commented on June 2, 2024

Ok, here is the example:

using MCMC

mymodel1 = model(v-> -dot(v,v), init=ones(3)) 
mychain = run(mymodel1, RWM(0.1), SerialMC(steps=1000, burnin=100))

# Compute the log-posterior for the first sample (i.e. first MCMC iteration)
mymodel1.eval(mychain.samples[1, :])

# Compute the log-posterior for all the samples
[mymodel1.eval(mychain.samples[i, :]) for i in 1:size(mychain.samples, 1)]

from klara.jl.

fredo-dedup avatar fredo-dedup commented on June 2, 2024

This is a good point, we should be parcimonious in the data stored especially for very long chains. On the other hand this would not significantly increase the memory requirements : we already store the parameter vector, gradient and diagnostics for each iteration, adding a single float will not change much. Secondly, recalculating the log-posterior after the run will take about the same time as the run itself so it is not viable for very long runs.

Perhaps we could add some kind of opting-out of the diagnostics produced ? (that the user could choose if allocations made at the run initiation fail).

from klara.jl.

papamarkou avatar papamarkou commented on June 2, 2024

Yes, maybe we can provide the user with the option of choosing what to return. At the same time, I think that if we decide to return the log-posterior, it should be a standalone field outside the diagnostics; we provide the gradient outside the diagnostics which is more secondary than the log-posterior.

from klara.jl.

fredo-dedup avatar fredo-dedup commented on June 2, 2024

@carloalbert : the current master should provide the return value of the function (in the field logtargets of the MCMCChain type).
The new version of MCMC is 0.0.6 (run Pkg.update())

from klara.jl.

Related Issues (20)

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.