Comments (3)
Hi @AxLamelas , thanks for letting me know about this. I'm checking into it now
from soss.jl.
The logdensity_def
problem is easily addressed by adding a primitive for that. I'm still seeing an issue after doing that. This problem can be reduced to
using Soss
mc_init = @model begin
x ~ Normal(0.0, 1.0)
return (x=x,)
end
mc_step = @model s begin
x ~ Normal(s.x + 0.1, 0.2)
return (x = x,)
end
d = Chain(mc_init()) do s mc_step(s=s) end
x = Iterators.take(rand(d), 10) |> collect
logdensity_def(d,x)
This gives the result
ERROR: MethodError: First argument to `convert` must be a Type, got (x = Float64,)
Stacktrace:
[1] macro expansion
@ ~/git/Soss.jl/src/primitives/logdensity.jl:92 [inlined]
[2] _logdensity_def(M::Type{Soss.GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}}, _m::Model{NamedTuple{(:p, :s)}, Soss.GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, Soss.GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}}, _args::NamedTuple{(:s, :p), Tuple{NamedTuple{(:x,), Tuple{Float64}}, NamedTuple{(:Δμ, :σ), Tuple{Float64, Float64}}}}, _data::NamedTuple{(), Tuple{}}, _pars::NamedTuple{(:x,), Tuple{Float64}})
@ Soss ~/git/Soss.jl/src/primitives/logdensity.jl:92
[3] logdensity_def(c::Soss.ConditionalModel{NamedTuple{(:p, :s)}, Soss.GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, Soss.GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(:s, :p), Tuple{NamedTuple{(:x,), Tuple{Float64}}, NamedTuple{(:Δμ, :σ), Tuple{Float64, Float64}}}}, NamedTuple{(), Tuple{}}}, x::NamedTuple{(:x,), Tuple{Float64}})
@ Soss ~/git/Soss.jl/src/primitives/logdensity.jl:51
[4] logdensity_def(mc::Chain{var"#19#20", Soss.ConditionalModel{NamedTuple{()}, Soss.GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, Soss.GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}}}, x::Vector{Any})
@ MeasureTheory ~/.julia/packages/MeasureTheory/MeOXc/src/combinators/chain.jl:28
[5] top-level scope
@ REPL[89]:1
from soss.jl.
I had hoped this would just be a matter of adding a logdensity_def
method. After adding this in #350, I still get the above error,
ERROR: MethodError: First argument to `convert` must be a Type, got (x = Float64,)
We can also look at the simpler example:
julia> mc_step = @model x begin
y ~ Normal(x + 0.1, 0.2)
return y
end;
julia> d = Chain(Normal()) do s mc_step(s) end;
julia> x = Iterators.take(rand(d), 10) |> collect;
julia> logdensity_def(d,x)
ERROR: MethodError: no method matching keys(::Type{Float64})
Closest candidates are:
keys(::Union{Tables.AbstractColumns, Tables.AbstractRow}) at ~/.julia/packages/Tables/PxO1m/src/Tables.jl:184
keys(::Missings.EachReplaceMissing) at ~/.julia/packages/Missings/r1STI/src/Missings.jl:94
keys(::DataStructures.Trie) at ~/.julia/packages/DataStructures/59MD0/src/trie.jl:82
...
Stacktrace:
[1] loadvals(argstype::Type, datatype::Type, parstype::Type)
@ Soss ~/git/Soss.jl/src/core/utils.jl:217
[2] #s112#76
@ ~/git/Soss.jl/src/primitives/logdensity.jl:92 [inlined]
[3] var"#s112#76"(::Any, M::Any, _m::Any, _args::Any, _data::Any, _pars::Any)
@ Soss ./none:0
[4] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core ./boot.jl:582
[5] logdensity_def(c::Soss.ConditionalModel{NamedTuple{(:x,)}, Soss.GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, Soss.GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(:x,), Tuple{Float64}}, NamedTuple{(), Tuple{}}}, x::Float64)
@ Soss ~/git/Soss.jl/src/primitives/logdensity.jl:50
[6] logdensity_def(mc::Chain{var"#11#12", Normal{(), Tuple{}}}, x::Vector{Any})
@ MeasureTheory ~/.julia/packages/MeasureTheory/Mrznp/src/combinators/chain.jl:28
[7] top-level scope
@ REPL[24]:1
So it looks like there's a place where types are mistakenly being treated as values. That kind of problem usually means it's a metaprogramming issue, maybe a generated function. But then it's also strange that other tests pass, included those for nested models. So it might have to do with the implementation of Chain
, or possible its interaction with the generated functions.
The errors I'm getting are kind of tricky to debug. I think a next step might be for me to implement this example in Tilde and see if I hit the same issue.
from soss.jl.
Related Issues (20)
- What am I doing wrong? HOT 3
- Examples page in documentation does not exist HOT 1
- sample(...) does not work HOT 9
- No more Soss.predict() methods for densities from Distributions.jl HOT 3
- Implemention of Gaussian mixture model fails when sampling the posterior HOT 4
- Collision of filenames on OS X HOT 3
- Int argument for predict function HOT 2
- Follow Traditional Style Guide? (At least in public API)
- Help fitting a simple t distribution HOT 4
- For(...) do i ... broken using Soss with [email protected] or later HOT 4
- Empty model in predict HOT 6
- Modeling discrete variables
- CSV interference HOT 1
- dynamicHMC UndefVarError
- Can't use M as variable name HOT 4
- Precompilation warning HOT 2
- Example in Readme fails HOT 7
- README example fails HOT 32
- Empty transform with (new) Soss.as HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soss.jl.