# Error when transfer learning with neural\_adapter

**URL:** https://discourse.julialang.org/t/error-when-transfer-learning-with-neural-adapter/101145
**Category:** General Usage
**Tags:** question, neural-network
**Created:** [July 3, 2023, 11:59pm UTC](https://discourse.julialang.org/t/error-when-transfer-learning-with-neural-adapter/101145 "2023-07-03T23:59:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)
#### Post date: [July 3, 2023, 11:59pm UTC](https://discourse.julialang.org/t/error-when-transfer-learning-with-neural-adapter/101145/1 "2023-07-03T23:59:37Z")

</div>

I tried to transfer the pre-trained weight from another model to retrain a new one by the code in the tutorial as follows:

```julia
function loss(cord,θ)
    chain2(cord,θ) .- phi(cord,res.u)
end

strategy = NeuralPDE.GridTraining(0.001)

prob_ = NeuralPDE.neural_adapter(loss, init_params = res.u.depvar, pde_system, strategy)
callback = function (p,l)
    println("Current loss is: $l")
    return false
end
res_ = Optimization.solve(prob_, BFGS();callback = callback, maxiters=100)

phi_ = NeuralPDE.get_phi(chain)

```

The chain and the system are the same structure just change the parameters.  
I got the message below:

```julia
MethodError: no method matching neural_adapter(::typeof(loss), ::PDESystem, ::GridTraining{Float64}; init_params::ComponentArrays.ComponentVector{Float64, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, Tuple{ComponentArrays.Axis{(u1 = ViewAxis(1:321, Axis(layer_1 = ViewAxis(1:32, Axis(weight = ViewAxis(1:16, ShapedAxis((16, 1), NamedTuple())), bias = ViewAxis(17:32, ShapedAxis((16, 1), NamedTuple())))), layer_2 = ViewAxis(33:304, Axis(weight = ViewAxis(1:256, ShapedAxis((16, 16), NamedTuple())), bias = ViewAxis(257:272, ShapedAxis((16, 1), NamedTuple())))), layer_3 = ViewAxis(305:321, Axis(weight = ViewAxis(1:16, ShapedAxis((1, 16), NamedTuple())), bias = ViewAxis(17:17, ShapedAxis((1, 1), NamedTuple())))))), u2 = ViewAxis(322:642, Axis(layer_1 = ViewAxis(1:32, Axis(weight = ViewAxis(1:16, ShapedAxis((16, 1), NamedTuple())), bias = ViewAxis(17:32, ShapedAxis((16, 1), NamedTuple())))), layer_2 = ViewAxis(33:304, Axis(weight = ViewAxis(1:256, ShapedAxis((16, 16), NamedTuple())), bias = ViewAxis(257:272, ShapedAxis((16, 1), NamedTuple())))), layer_3 = ViewAxis(305:321, Axis(weight = ViewAxis(1:16, ShapedAxis((1, 16), NamedTuple())), bias = ViewAxis(17:17, ShapedAxis((1, 1), NamedTuple())))))))}}})

Closest candidates are:
  neural_adapter(::Any, ::Any, ::Any, ::Any) got unsupported keyword argument "init_params"
   @ NeuralPDE C:\Users\htran\.julia\packages\NeuralPDE\PL790\src\neural_adapter.jl:120
  neural_adapter(::Array, ::Any, ::Array, ::Any) got unsupported keyword argument "init_params"
   @ NeuralPDE C:\Users\htran\.julia\packages\NeuralPDE\PL790\src\neural_adapter.jl:130

Stacktrace:
 [1] top-level scope
   @ In[79]:23

```

Please help me on how to fix it.  
thank you all.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [July 14, 2023, 1:00pm UTC](https://discourse.julialang.org/t/error-when-transfer-learning-with-neural-adapter/101145/2 "2023-07-14T13:00:34Z")

</div>

Neural adapter was pulled from the docs IIRC because it wasn’t working since the v5 update. We’ll need to bring it back, but for now it has had a temporary deprecation until we have the time to update it.
