Skip to content

Commit

Permalink
Fixes to text decoding example
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoct committed Jul 2, 2019
1 parent d98bb2e commit 6109388
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 260 deletions.
254 changes: 0 additions & 254 deletions examples/decode/Manifest.toml

This file was deleted.

3 changes: 0 additions & 3 deletions examples/decode/Project.toml

This file was deleted.

7 changes: 4 additions & 3 deletions examples/decode/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function swap_involution(trace, fwd_choices::ChoiceMap, fwd_ret, proposal_args::
constraints[replica => :text => l] = new_char
end

(new_trace, weight, _, _) = update(trace, model_args, noargdiff, constraints)
(new_trace, weight, _, _) = update(trace, model_args, (NoChange(),), constraints)
(new_trace, bwd_choices, weight)
end

Expand All @@ -94,7 +94,7 @@ function exchange_involution(trace, fwd_choices::ChoiceMap, fwd_ret, proposal_ar
replica_plus_one = (((replica-1)+1)%num_replicas)+1
set_submap!(constraints, replica_plus_one, get_submap(choices, replica))
set_submap!(constraints, replica, get_submap(choices, replica_plus_one))
(new_trace, weight, _, _) = update(trace, model_args, noargdiff, constraints)
(new_trace, weight, _, _) = update(trace, model_args, (NoChange(),), constraints)
(new_trace, EmptyChoiceMap(), weight)
end

Expand Down Expand Up @@ -132,6 +132,7 @@ function do_inference(encoded_text::AbstractString, num_iter::Int)

# do MCMC
for iter=1:num_iter
println("iter: $iter")

# print state
if (iter - 1) % 1 == 0
Expand Down Expand Up @@ -195,4 +196,4 @@ original_text_int = map((char) -> letter_to_int[char], collect(original_text))
encoded_text = join(map((letter_int) -> alphabet[letter_int], code[original_text_int]))
println("encoded text:")
println(encoded_text)
do_inference(encoded_text, 100000)
do_inference(encoded_text, 1000)
1 change: 1 addition & 0 deletions examples/run_examples.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Gen
using Test

include("decode/run.jl")
include("regression/static_mala.jl")
include("regression/static_map_optimize.jl")
include("regression/static_mh.jl")
Expand Down

0 comments on commit 6109388

Please sign in to comment.