FluxML/Flux.jl

Add docs note about saving/loading models with anonymous functions

Chiusa

#2263 aperta il 9 giu 2023

 (9 commenti) (1 reazione) (0 assegnatari)Julia (619 fork)batch import
documentationhelp wanted

Metriche repository

Star
 (4725 stelle)
Metriche merge PR
 (Merge medio 3g 6h) (6 PR mergiate in 30 g)

Descrizione

The new save/load docs promote JLD2.jl which does not support saving/loading anonymous functions reliably. This most commonly occurs for activation functions. The solution is to use Flux.state + Flux.loadmodel! and set the desired anonymous function in the destination of loadmodel!. This avoids needing the serialization library to correctly handle the anonymous function.

This will be problematic when the anonymous function contains data (state) that actually should be restored. A possible solution here is to make the closure an explicit struct. Maybe there are better solutions.

Regardless, new users are unlikely to realize these edge cases. We should expand the saving/loading documentation to explain how to handle these cases with code examples.

Guida contributor