# Freezing neural network parameters in Universal Differential Equation framework

**URL:** <https://discourse.julialang.org/t/freezing-neural-network-parameters-in-universal-differential-equation-framework/99661>\
**Category:** Modelling & Simulations\
**Created:** [May 31, 2023, 9:16am UTC](https://discourse.julialang.org/t/freezing-neural-network-parameters-in-universal-differential-equation-framework/99661 "2023-05-31T09:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefano\_Giampiccolo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefano_giampiccolo/32/46018_2.png) [@Stefano\_Giampiccolo](https://discourse.julialang.org/u/Stefano_Giampiccolo)\
**Post date:** [May 31, 2023, 9:16am UTC](https://discourse.julialang.org/t/freezing-neural-network-parameters-in-universal-differential-equation-framework/99661/1 "2023-05-31T09:16:11Z")

</div>

Hi,  
I’m working on hybrid systems with the SciML framework, approximating one of the derivatives of an ODE system with a neural network. When I attempt, using Lux.freeze, to freeze some of the network parameters that I don’t want to be optimized (for example the weights in the snippet that I’ve attached), I get the following error during optimization:

> ERROR: MethodError: no method matching \_merge(::ReverseDiff.TrackedArray{Float64, Float64, 1, ComponentVector{Float64, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, Tuple{Axis{(weight = ViewAxis(1:10, ShapedA …

[snippet\_fail\_frozen\_layer.jl](https://discourse.julialang.org/uploads/short-url/iZUzQtJKuYocCus5ips5VcPhON5.jl) (2.3 KB)

Could you kindly point out what I am doing wrong?  
Thank you in advance, Stefano

I am using Julia v"1.8.5" with the following packages  
ComponentArrays v0.13.7  
DifferentialEquations v7.7.0  
Lux v0.4.36  
Optimization v3.11.2  
OptimizationOptimisers v0.1.1  
SciMLSensitivity v7.20.0  
StableRNGs v1.0.0

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [May 31, 2023, 9:41am UTC](https://discourse.julialang.org/t/freezing-neural-network-parameters-in-universal-differential-equation-framework/99661/2 "2023-05-31T09:41:41Z")

</div>

I tried running your code and didn’t get any error. I used Julia 1.9 and a freshly updated environment with the packages though, so it is probably just something small that has been fixed since your package versions. I would suggest to first just update your packages and see if that is enough, and if not try it with Julia 1.9 and see if that helps.

---

<div class="post-metadata">

**Author:** ![Stefano\_Giampiccolo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefano_giampiccolo/32/46018_2.png) [@Stefano\_Giampiccolo](https://discourse.julialang.org/u/Stefano_Giampiccolo)\
**Post date:** [May 31, 2023, 9:44am UTC](https://discourse.julialang.org/t/freezing-neural-network-parameters-in-universal-differential-equation-framework/99661/3 "2023-05-31T09:44:25Z")

</div>

Thank you! I’ll try it
