Comments (4)
Here's a MWE, removed from Soss:
julia> using Soss, MeasureTheory, GeneralizedGenerated
julia> g = GG.mk_function(:(x -> Normal(x,1)))
function = (x;) -> begin
begin
(GeneralizedGenerated).Normal(x, 1)
end
end
julia> For(g, 3)
ERROR: MethodError: no method matching productmeasure(::ggfunc-function, ::UnitRange{Int64})
Closest candidates are:
productmeasure(::Any, ::Any, ::Any) at /home/chad/git/MeasureBase/src/combinators/smart-constructors.jl:69
productmeasure(::Kernel, ::Any) at /home/chad/git/MeasureBase/src/combinators/smart-constructors.jl:75
productmeasure(::Returns, ::Any, ::Any) at /home/chad/git/MeasureBase/src/combinators/smart-constructors.jl:82
...
Stacktrace:
[1] For(f::ggfunc-function, n::Int64)
@ MeasureBase ~/git/MeasureBase/src/combinators/for.jl:82
[2] top-level scope
@ REPL[53]:1
mk_function
calls GeneralizedGenerated.closure_conv
, which produces
julia> typeof(g)
ggfunc-function
julia> typeof(g) |> supertype
Any
So the issue is that MeasureBase.productMeasure
doesn't have a generic method, but wants a <:Function
, and a ggfun-function
doesn't meet this criteria.
The simplest fix for this is to add a method
productmeasure(f, pars) = productmeasure(f, identity, pars)
For example, this works:
julia> MeasureBase.productmeasure(f, pars) = MeasureBase.productmeasure(f, identity, pars)
julia> m = @model begin
x ~ For(3) do j Normal(j,1) end
end;
julia> rand(m())
(x = [1.9296440232404293, 3.1574221730525336, 4.1352330633979255],)
But it turns out this just kicks the can down the road:
julia> logpdf(m(), rand(m()))
ERROR: MethodError: no method matching basekernel(::ggfunc-function)
Closest candidates are:
basekernel(::Kernel) at /home/chad/git/MeasureBase/src/kernel.jl:73
basekernel(::Returns) at /home/chad/git/MeasureBase/src/kernel.jl:74
basekernel(::Function) at /home/chad/git/MeasureBase/src/kernel.jl:71
To be continued...
from soss.jl.
Thanks for the quick fix!
from soss.jl.
Thanks for letting me know about this! This is a high priority to fix, obviously. I think (hope?) it should be a quick fix, then we should add tests to be sure to catch this going forward. I'll spend some time on it today.
from soss.jl.
Hi @Tuebel , thanks again for this issue. There's a new release with tests that include
@testset "https://github.com/cscherrer/Soss.jl/issues/305" begin
m = @model begin
x ~ For(3) do j Normal(μ=j) end
end;
@test logpdf(m(), rand(m())) isa Float64
end
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
- 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
- Unable to sample posterior of the MC example from JuliaCon 2021 HOT 3
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.