2017-07-30 19 views
0

私はモデルを保存してトレーニングを開始するたびにモデルを保存しようとしています。私はちょうどthis linkが行ったことに従った。TensorFlow:モデルを復元する

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") 

しかし、それは下のエラーを与える:

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

誰も私を助けることができるしてください?どうもありがとう!

+0

から読み込む(また、あなたがないことをあなたのために。復元、変数を開始する必要はありません)./models/とロード「./」パスを修正しようとしましたか? – lejlot

+0

ええ、最初は復元せずにコードを実行し、上記のコードを実行しました。 –

答えて

0

./をロードする場合は、実際にそのディレクトリ(models /)にコンソール(pythonプログラムを起動するために使用する)が設定されていることを確認する必要があります。 しかしその場合、新しいディレクトリに新しいデータが保存されます。だからではなく、

あなたは、「モデル/モデル」まだに保存されている
+0

これは本当に今働きます!多くの@ Xethoras soooooをありがとう。あなたをブレス! –

関連する問題