# Saving Flux models

**URL:** <https://discourse.julialang.org/t/saving-flux-models/99013>\
**Category:** General Usage\
**Tags:** flux\
**Created:** [May 17, 2023, 7:25pm UTC](https://discourse.julialang.org/t/saving-flux-models/99013 "2023-05-17T19:25:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cirobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cirobr/32/219994_2.png) [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Post date:** [May 17, 2023, 7:25pm UTC](https://discourse.julialang.org/t/saving-flux-models/99013/1 "2023-05-17T19:25:43Z")

</div>

Checking documentation for current stable Flux v0.13.16, I am wondering why it is suggested so many transformations (struct, functor) prior to saving a model with Flux.state(transformed\_model).

In which sense just saving Flux.state(model) is not preferred?

Preferred saving method follows here for reference:

```julia
julia> using Flux

julia> struct MyModel
           net
       end

julia> Flux.@functor MyModel

julia> MyModel() = MyModel(Chain(Dense(10, 5, relu), Dense(5, 2)));

julia> model = MyModel()
MyModel(Chain(Dense(10 => 5, relu), Dense(5 => 2)))

julia> model_state = Flux.state(model);

julia> using JLD2

julia> jldsave("mymodel.jld2"; model_state)

```

Thanks.
