GithubHelp home page GithubHelp logo

Comments (6)

cscherrer avatar cscherrer commented on May 27, 2024

Just found this:
JuliaLang/julia#37517

If I'm reading this right, it seems that in 1.6 will return a ComposedFunction instead of an anonymous one. So at that point all of this will work. But I'm on 1.5, which is why I'm seeing strange results. Does that sound right?

from accessors.jl.

jw3126 avatar jw3126 commented on May 27, 2024

hi, I'm starting to think Accessors can be a big role in Soss, not just as a library, but also in the generated code I use for sampling. The idea would be to have a collection of optics for each model, and compose these to descend into submodels.

Sounds really exciting I need to check this out.

If I'm reading this right, it seems that in 1.6 ∘ will return a ComposedFunction instead of an anonymous one. So at that point all of this will work. But I'm on 1.5, which is why I'm seeing strange results. Does that sound right?

I think you can just dispatch on Accessors.ComposedOptic. Accessors.jl does this also internally. On 1.5 it is an alias for the scary looking var"...". On 1.6 it is an alias for Base.ComposedFunction.
Other than the bad printing, I did not encounter any problems on 1.5.

from accessors.jl.

cscherrer avatar cscherrer commented on May 27, 2024

I need to check this out

It's mostly here, specifically in

function sourceSample() 
    function(m::Model)
        
        _m = canonical(m)
        proc(_m, st::Assign)  = :($(st.x) = $(st.rhs))
        proc(_m, st::Sample)  = :($(st.x) = value(sample(_rng, $(st.rhs))))
        proc(_m, st::Return)  = :(_value = $(st.rhs))
        proc(_m, st::LineNumber) = nothing

        vals = map(x -> Expr(:(=), x,x),parameters(_m)) 

        wrap(kernel) = @q begin
            _rng -> begin
                _value = nothing
                $kernel
                _trace = $(Expr(:tuple, vals...))
                return (value = _value, trace = _trace)
            end
        end

        buildSource(_m, proc, wrap) |> flatten
    end
end

The trace property will contain values for latent variables. But one of those might itself be the output of a model, in which case we need to keep track of its latent variables as well. So I'm thinking I can pass an optic to represent the current scope.

I think you can just dispatch on Accessors.ComposedOptic. Accessors.jl does this also internally. On 1.5 it is an alias for the scary looking var"...". On 1.6 it is an alias for Base.ComposedFunction.
Other than the bad printing, I did not encounter any problems on 1.5.

Great! I'll try this, thanks :)

from accessors.jl.

cscherrer avatar cscherrer commented on May 27, 2024

Confirmed!!

julia> using Accessors

julia> outeroptic(::Accessors.ComposedOptic{A,B}) where {A,B} = A
outeroptic (generic function with 1 method)

julia> o = @optic _.a.b
(@optic _.b)  (@optic _.a)

julia> outeroptic(o)
Accessors.PropertyLens{:b}

from accessors.jl.

cscherrer avatar cscherrer commented on May 27, 2024

Just opened cscherrer/Soss.jl#227

I think this is resolved on the Accessors side, thanks @jw3126

from accessors.jl.

cscherrer avatar cscherrer commented on May 27, 2024

Oh, last post here wasn't clear. I mean I'll close the issue, since it's currently more an issue on the Soss side. @jw3126 if you're interested I'd welcome any feedback there :)

from accessors.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.