Importing Pre-Trained Model in Julia

Is there an effective way to import a pre-trained model (or at least the model specification and weights) in Julia and use it in TensorFlow.jl?
If not, are there other ways to load in a pre-trained BLSTM and work with it in Julia? I’ve looked into ONNX, but haven’t found yet a working example.

1 Like

You can load model specifications from python tensorflow into TensorFlow.jl using the import metagraph, (in theory).

You can’t load weights IIRC as at the time TensorFlow.jl was developed there was no public standard for how python tensorflow stored them.


KNET seems to have out of the box support for bidirectional LSTMs:

With Flux I guess you should be able to craft your own by just using two LSTM layers (and I can’t rule out that there is some other secret way this works in Flux).

As for importing a pre-trained model, ONNX.jl does not seem to handle birectional LSTM and neither does my own atm. If you file an issue on the latter (or better, a PR) I can try to add it tonight.

If you just want to do something fast both ONNX.jl and ONNXmutable.jl allow you override the LSTM mapping function with your own function definition by just replacing the :LSTM mapping in a dict.