baggepinnen / FluxOptTools.jl

Use Optim to train Flux models and visualize loss landscapes
MIT License
59 stars 4 forks source link

Use restructure/destructure #4

Open ChrisRackauckas opened 4 years ago

ChrisRackauckas commented 4 years ago

The README states:

The utility provided by this package is the function optfuns which returns three functions and p0, a vectorized version of pars.

This is now covered by Flux.destructure, which is featured in the DiffEqFlux.jl README:

https://github.com/JuliaDiffEq/DiffEqFlux.jl#neural-ordinary-differential-equations

rs1909 commented 4 years ago

Hi @ChrisRackauckas , could you explain how to use Flux.destructure just to fit a function with Flux and Optim? It is not documented in Flux. Thx

ChrisRackauckas commented 4 years ago

p,re = Flux.destructure(ann) gives the parameters of the neural network and a restructure function. re(p) gives back a new neural network that matches ann in structure but uses the parameters p.