Flux.jl/docs/src/apis/storage.md
Mike J Innes 2de6b063ad typo
2017-02-28 17:02:07 +00:00

989 B
Raw Blame History

Loading and Saving Models

model = Chain(Affine(10, 20), σ, Affine(20, 15), softmax)

Since models are just simple Julia data structures, it's very easy to save and load them using any of Julia's existing serialisation formats. For example, using Julia's built-in serialize:

open(io -> serialize(io, model), "model.jls", "w")
open(io -> deserialize(io), "model.jls")

One issue with serialize is that it doesn't promise compatibility between major Julia versions. For longer-term storage it's good to use a package like JLD.

using JLD
@save "model.jld" model
@load "model.jld"

However, JLD will break for some models as functions are not supported on 0.5+. You can resolve that by checking out this branch.

Right now this is the only storage format Flux supports. In future Flux will support loading and saving other model formats (on an as-needed basis).