When using Flux.jl to build neural network, I want to build a hybrid NN.
I found [Flux.PairwiseFusion
] (Built-in Layers · Flux) can meet my need.
But when I train the NN:
using Flux
using Statistics
using Flux: train!
m2 = PairwiseFusion(vcat, Dense(1,1), Dense(2,1))
x1, x2 = hcat(0:4...), hcat(6:10...)
actual(x) = 4x + 2
y = actual.(x1)
data = [((x1,x2), y)]
loss(m, (xa,xb), yt) = mean(abs2.(m(xa,xb)[2].-yt))
loss(m2, (x1,x2), y)
opt = Descent()
data = [(((x1,x2)),y)]
train!(loss, m2, data, opt)
Errors are
MethodError: no method matching train!(::typeof(loss), ::PairwiseFusion{typeof(vcat), Tuple{Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}, ::Vector{Tuple{Tuple{Matrix{Int64}, Matrix{Int64}}, Matrix{Int64}}}, ::Descent)
Closest candidates are:
train!(::Any, !Matched::Zygote.Params, ::Any, ::Flux.Optimise.AbstractOptimiser; cb) at C:\Users\Lenovo\.julia\packages\Flux\EXOFx\src\optimise\train.jl:113
in eval at base\boot.jl:368
in top-level scope at test.jl:134
What can I do?
Thanks very much!