(speculative) turn `model.f` parameters into ConditionContext

Aperta
#958 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

  • #1468 di @yebai — chiusa senza merge
  • #1501 di @yebai — chiusa senza merge

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
20/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
julia
Ambito
compilers

Direzione di ricerca

Inizia con la macro @model, i nomi e i valori degli argomenti memorizzati dell’oggetto Model e la gestione di ConditionContext; confrontali con il comportamento di .~ descritto in #804. Definisci se gli argomenti del modello debbano essere unificati con il condizionamento o rifiutati insieme a esso, quindi verifica che l’esempio non presenti più un comportamento indefinito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Right now we have two ways of conditioning, one through model arguments and one through contexts. However, it's unclear what happens if someone tries to do it both ways.

@model function f(a=1.0)
    a ~ Normal()
    return a
end

m = f()
cm = m | (; a=2.0)

cm() # returns 1.0, i.e. conditioning is ignored, but this behaviour is undefined

The cheapest fix would be to warn or error when somebody tries to condition on a model argument. (We can do this because the argument names, and values, are stored in the Model object.)

A different fix would be to somehow unify the two ways together, so that for example when one declares f(2.0) it's really turned into f without an argument, but with a ConditionContext.

I actually think this would be good. I used to have some concerns about ConditionContext, but that was all fixed since we simplified .~ (#804), and now I think it's much better than the old argument-passing. But I don't immediately know from a technical standpoint how to do this. (I think we would have to do some macro magic to generate a new method for f without arguments, then forward the f-with-arguments method to the f-without-arguments method.) In this case, as long as we prevent conditioning twice on the same variable we would avoid the undefined behaviour..

@yebai points out that having static parameter declaration a la of would solve this, though of course we are unsure when that will be ready.

Lingua principale
Julia
Stelle
291
Fork
43
Merge medio
1g 23h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TuringLang/DynamicPPL.jl

Tutte le issue di TuringLang/DynamicPPL.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.