Giter Site home page Giter Site logo

Comments (2)

avik-pal avatar avik-pal commented on June 3, 2024 1

Verified locally that the suggested patch works:

function (m::CustomModel)(x, ps, st::NamedTuple)
    rezi_T = 1000/x[n_species+1]
    Ns = x[1:n_species]
    model_inp = vcat(log10.(Ns), rezi_T)
    k, st_k = m.k_model(model_inp, ps.k_model, st.k_model)
    ks = 10 .^ k
    eff_Ns =  vec(prod(Ns .^ -min.(stoich_m', 0.), dims=1))
    qk = eff_Ns .* ks
    dN = vec(sum(qk .* stoich_m, dims=1))
    uscp, st_t = m.t_model([rezi_T], ps.t_model, st.t_model)
    us = 1e8 .* uscp[1:n_species]
    cp = sum((1e4 .* uscp[n_species+1:n_species*2]) .* Ns)
    dU = sum(us .* dN)
    dT = -dU/cp
    result = vcat(dN,dT)
    return result, (k_model = st_k, t_model = st_t)
end

from lux.jl.

avik-pal avatar avik-pal commented on June 3, 2024

Try changing result = vcat(dN...,dT) to not use splatting. Something like vcat(dN, dT) should work. If you splat, Zygote doesn't preserve the Vector structure

For NeuralODEs most of the sensitivity algorithms assume a flat parameter structure (unlike the default return type which is a nested named tuple). See https://lux.csail.mit.edu/dev/tutorials/intermediate/1_NeuralODE#training, it describes some Adjoints which don't require the flat parameter structure.

from lux.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.