Skip to content Skip to sidebar Skip to footer

Tensorflow - Saving A Model

I have the following code, and getting an error when trying to save the model. What could I be doing wrong, and how can I solve this issue? import tensorflow as tf data, labels =

Solution 1:

It seems like the folder in which you want to store the model does not exist (may be check what your current working directory is). To avoid those issues, I would use absolute paths and before saving do something like this:

save_path = ...
ifnotos.path.exists(save_path):
    os.makedirs(save_path)
...
saver = tf.train.Saver()
with tf.Session() as sess:
    ...
    saved_path = saver.save(sess, os.path.join(save_path, 'my_model')
    print("The model is in this file: ", saved_path)

Solution 2:

you can use too saved_path = saver.save(sess, './mymodel')

Post a Comment for "Tensorflow - Saving A Model"