Hi. I have a problem on gradient descend in Flux.
Suppose I have a model like this:
model1 = Chain(x->Dense(5,5),relu)
model2 = Chain(x->model1(x), Dense(5,5), vec)
model3 = Chain(x->model1(x), Dense(5,5), vec)
And I wrap them in params:
parameters = Flux.params(model1,model2,model3)
And I use gradient descend:
gs = gradient(parameters) do
loss1 = model2(x) - trueX
loss2 = model3(y) - trueY
loss = loss1 + loss2
end
My target is to learn two things. They are both learnt from model1, but I use model2 to output one thing and model3 to output the other. I am curious whether I can use codes above to realize it.
Thank you!