Handle fixing and conditioning together
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
Direzione di ricerca
Inizia dalle righe 448-461 di src/compiler.jl e segui la logica getconditioned/getfixed per le operazioni annidate di condition e fix. Esamina il test di regressione previsto in test/submodel.jl e la rappresentazione esistente di CondFixContext. Il lavoro è completato quando l'operazione di conditioning o fixing più esterna ha la precedenza in modo coerente per tutte e quattro le coppie di operazioni, con test che coprono questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Consider:
using DynamicPPL, Distributions
for op1 in [condition, fix]
for op2 in [condition, fix]
@model g() = x ~ Normal()
g_op = op1(g(), (; x = 1.0))
@model f() = a ~ to_submodel(g_op)
f_op = op2(f(), (@varname(a.x) => 2.0))
println("$op1 $op2 => $(f_op())")
end
end
The result (last tested on DynamicPPL 0.41):
condition condition => 2.0
condition fix => 2.0
fix condition => 1.0
fix fix => 2.0
For fixfix and concon, there's no issue because the values are merged in a way that respects the outer. (it's somewhere in getconditioned / getfixed I think)
For confix and fixcon, unfortunately, the logic in the codebase says that fixing always takes precedence over conditioning, because fix is in the first branch and condition is in the last branch
I discovered while writing tests for nested condition/fix. This was the test I had intended to add to test/submodel.jl.
@testset "precedence for conditioning/fixing the same variable twice" begin
# Check that the outermost conditioning takes precedence. I'm not sure
# if there is a strong a priori reason for this, but it is currently
# the case and thus this test just ensures that the behaviour doesn't
# suddenly change without it being a conscious decision to do so.
@testset "$op1,$op2" for op1 in [condition, fix], op2 in [condition, fix]
@model function f()
x ~ Normal()
end
fcond = op1(f(), (; x=1.0)) # this is ignored
@model function g()
return a ~ to_submodel(fcond)
end
gcond = op2(g(), (@varname(a.x) => 2.0)) # this takes precedence
@test gcond() == 2.0
end
end
How to solve?
Right now, conditioning and fixing go via what's now called CondFixContext. However, the conditioned values and fixed values are still stored in separate 'layers' of this.
The way to prevent this would be to 'flatten' the layers such that conditioned variables and fixed variables are part of the same VarNamedTuple. They would be held inside a VNT together with a flag that indicates whether it's conditioned or fixed. Thus instead of having a data structure that holds two VNTs, one conditioned and one fixed, we would only have one VNT that holds both.
We could then use templated_setindex_no_overwrite!! or something similar to issue an error when attempting to fix a variable that is already conditioned.
- Lingua principale
- Julia
- Stelle
- 291
- Fork
- 43
- Merge medio
- 1g 23h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TuringLang/DynamicPPL.jl
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
TuringLang/DynamicPPL.jl#1499 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
TuringLang/DynamicPPL.jl#1480 ·
I maintainer di solito rispondono entro 2 giorni
-
Separate model-evaluation inputs from outputsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertadata-structures enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
TuringLang/DynamicPPL.jl#1469 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
TuringLang/DynamicPPL.jl#1466 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
TuringLang/DynamicPPL.jl#1390 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di TuringLang/DynamicPPL.jl
Issue simili
-
Release CorleoneInverse as 0.1.1Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
SciML/Corleone.jl#200 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
JuliaAI/MLJTransforms.jl#120 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
exercism/julia#1205 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
SciML/OrdinaryDiffEq.jl#5175 ·
I maintainer di solito rispondono entro 1 giorno