-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexpect result when use build_function for Lux.jl-based expr #1187
Comments
It has a registration rule for symbolic arrays, but arrays of symbolic variables is missing form the dispatch. |
I built a symbolic array and found that it can indeed be replaced, as shown below:
But when I call this function, there is still a type conversion problem: |
@SebastianM-C can you point how this is different from the ModelingToolkitNeuralNets code? |
Yes, there are a couple things to note
Also, I'm not sure why are you using only the first element of the |
Thanks, here is my response:
This works, but I still want to construct it in a way like LuxCore.stateless_apply(nn, [v1, v2, v3, v4], lazyconvert_p)[1] because the indices of the vector v are calculated separately using different formulas. I want to combine the results into a vector as the input to the chain. |
Solved by using SymbolicUtils.jl, see the code as below:
|
I want to combine multiple expressions to build a function without intermediate calculated values. Refer to https://discourse.julialang.org/t/how-can-i-improve-the-computational-performance-of-my-code-odeproblem-solving/114425/9. When these expressions are ordinary variables, it is possible to complete the construction of this function by replacing intermediate variables. However, when expressions are generated by Lux.jl models, the build_function does not work well:
The generated function
temp_func = build_function(exprs, [v1, v2, v3, v4], expression=Val{false})
is:In this function, some variables such as v1, v2, etc., are not replaced by _arg1. Additionally, when calling this function
temp_func([3, 2, 1, 2], [ComponentVector(init_params), eltype(ComponentVector(init_params))])
, there is also a type conversion issue:The text was updated successfully, but these errors were encountered: