I have a trained neural network, which is already giving good results, and I’d like to use the parameters previously obtained for the model as the starting parameters to train the ANN on a new task (basically, it’s a transfer learning problem). So far, I’m training the network by using the following function"

```
function flux_training(x_train::Array{Float64,2}, y_train::Array{Float64,2}, n_epochs::Int, lambda::Int)
model = Chain(Dense(54,54,sigmoid),Dense(54,54,sigmoid),Dense(54,12,leakyrelu))
loss(x,y) = Flux.mse(model(x),y)
ps = params(model)
dataset = Flux.Data.DataLoader(x_train', y_train', batchsize = 32, shuffle = true)
opt = Optimiser(WeightDecay(lambda), ADAGrad())
evalcb() = @show(loss(x_train', y_train'))
for epoch in 1:n_epochs
println("Epoch $epoch")
time = @elapsed Flux.train!(loss, ps, dataset, opt, cb=throttle(evalcb,3))
end
y_hat = model(x_train')'
return y_hat, model
end
```

and I save the model created by doing:

```
weights = params(model)
using BSON: @save
@save "mymodel.bson" weights
```

How can I initialize the weights in my training function as the values that were previously saved, to train the ANN for a new task?