0

I'm trying to save my model at the end of triaining and restore it every time the training begins. I just followed what this link did.

    saver = tf.train.Saver()
    with tf.Session(graph=graph) as session:
        # Initializate the weights and biases
        tf.global_variables_initializer().run()
        new_saver = tf.train.import_meta_graph('model.meta')
        new_saver.restore(sess,tf.train.latest_checkpoint('./'))
        W1 = session.run(W)
        print(W1)

        for curr_epoch in range(num_epochs):
            train_cost = train_ler = 0
            start = time.time()
            for batch in range(num_batches_per_epoch):
                ...Some training...

        W2 = session.run(W)
        print(W2)
        save_path = saver.save(session, "models/model")

But it gives error below:

--->  new_saver.restore(session, tf.train.latest_checkpoint('./'))
SystemError: <built-in function TF_Run> returned a result with an error set

Can anyone help me please? Many thanks!

Johnnie Kang
  • 15
  • 1
  • 6

1 Answers1

0

If you're gonna load with ./ you have to make sure, that your console (that you use to start the python program) is actually set on that directory (models/). But in that case, it will save your new data in a new directory. So load with ./models/ instead

(Also you don't need to initiate variables, the restore does that for you.)

Xethoras
  • 26
  • 5