Satarupa Guha
Satarupa Guha

Reputation: 1307

ImportError: cannot import name 'persist'

I want to persist a trained model in CNTK and found the 'persist' functionality after some amount of searching. However, there seems to be some error in importing it.

from cntk import persist

This is throwing ImportError.

Am I doing something the wrong way? Or is this no longer supported? Is there an alternate way to persist a model?

Upvotes: 2

Views: 1014

Answers (2)

chrisbasoglu
chrisbasoglu

Reputation: 357

persist is from an earlier beta. save_model is now a method of every CNTK function. So instead of doing save_model(z, filename) you do z.save_model(filename). Load_model works the same as before but you import it from cntk.ops.functions. For an example, see: https://github.com/Microsoft/CNTK/blob/v2.0.beta7.0/Tutorials/CNTK_203_Reinforcement_Learning_Basics.ipynb or https://github.com/Microsoft/CNTK/blob/v2.0.beta7.0/bindings/python/cntk/tests/persist_test.py

Upvotes: 1

Nikos Karampatziakis
Nikos Karampatziakis

Reputation: 2050

The functionality has moved to cntk functions. The new way is mynetwork.save_model(...) where mynetwork represents the root of your computation (typically the prediction). For loading the model you can just say mynetwork = C.load_model(...)

Upvotes: 1

Related Questions