ReactiveBayes / GraphPPL.jl

DSL for probabilistic models specification and probabilistic programming.
MIT License
32 stars 5 forks source link

Array on `lhs` that will be initialized by submodel doesn't work #223

Closed wouterwln closed 3 months ago

wouterwln commented 5 months ago

We want to support the following model definition:

prelu(x) = x > 0 ? x : 0.01 * x

@model function artificial_neuron(data, out)
    w ~ Normal(0, 1)
    p_out := w * data
    out ~ prelu(p_out)
end

@model function neural_net_layer(indata out, width)
    for i in 1:width
        for j in eachindex(data)
            out[i] ~ artificial_neuron(data=data[j])
        end
    end
end

@model function my_model(data, out)
    hidden ~ neural_net_layer(data=data, width=5)
    out ~ neural_net_layer(data=hidden, width=1)
end