Simple Knet.jl Question: save/load model?

I’m new to julia (as of last week; toyed a bit long time ago with v0.2). I’ve looked over previous Knet posts, searched docs, and Knet (stable) source but can’t find an example of saving/loading a model.

I see what look like some examples of loading or saving a model, but in the knet source these are in the deprecated directory… for example model = gpucopy(load(opts["modelfile"],"model")) in Knet predict.jl deprecated example … or this in the deprecated s2s.jl # todo: implement load/save: revive cpucopy - done

Could someone point me to an example or help me with how one saves and loads an pre-trained model?

What I’m trying to do: I’m evaluating julia for use in my company. Ideally I’d like to build ML/DL models and provide a backend “prediction” API… doing all of that in 1 language would be awesome!

One option is to build the graph (and likely train) in python-tensorflow then use go-tensorflow (maybe to train, definitely to serve the model) with go http server.

I’t might also be cool to see if I could build in Knet (or flux) and see if I could somehow serve the model from go (my understanding though is that would not be straightforward).

They are using the JLD.jl library. I would instead suggest using JLD2.jl

https://github.com/simonster/JLD2.jl

It’ll save pretty much anything. But one thing to remember is you have to using KNet before loading in order for it to know how to rebuild the types.

1 Like

sweet, thanks. Gonna check it out. I’m thrilled (and a bit overwhelmed) at the number of projects in julia’s ecosystem. Just got done scanning down the list of packages in JuliaML… :astonished:

1 Like