Git Product home page Git Product logo

Comments (3)

fsaad avatar fsaad commented on June 2, 2024

Related #506

from gen.jl.

ztangent avatar ztangent commented on June 2, 2024

Thanks for catching this!

So I'm trying to understand why the line of code you identified was introduced in the first place, and it looks like @alex-lew added it in this old commit: c8ce0d7

Apparently it was introduced to address cases where things were being discarded, but shouldn't be. So maybe we can check if the fix you suggested @fsaad also passes the original test case that @alex-lew added?

This is the test case:

# Addresses under the :data namespace will be visited,
# but nothing there will be discarded.
@gen function loopy()
a = @trace(normal(0, 1), :a)
for i=1:5
@trace(normal(a, 1), :data => i)
end
end
# Get an initial trace
constraints = choicemap()
constraints[:a] = 0
for i=1:5
constraints[:data => i] = 0
end
(trace,) = generate(loopy, (), constraints)
# Update a
constraints = choicemap()
constraints[:a] = 1
(new_trace, weight, retdiff, discard) = update(trace,
(), (), constraints)
# Test discard, score, weight, retdiff
@test get_value(discard, :a) == 0
prev_score = logpdf(normal, 0, 0, 1) * 6
expected_new_score = logpdf(normal, 1, 0, 1) + 5 * logpdf(normal, 0, 1, 1)
expected_weight = expected_new_score - prev_score
@test isapprox(expected_new_score, get_score(new_trace))
@test isapprox(expected_weight, weight)
@test retdiff === UnknownChange()

from gen.jl.

ztangent avatar ztangent commented on June 2, 2024

This issue also seems highly related, but @alex-lew identified a different line of code in add_unvisited_to_discard! as the likely culprit, so maybe it's a different issue?

#237

from gen.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.