.ckptファイルとして保存していません。対話型プログラムでは、システム出力から、そのファイルが正常に作成されたことがわかりましたが、ファイルシステムでそのファイルを見つけることはできません。Tensorflowセーバー()私は「spikes.cpkt」としてディスクにTensorflowセッションを保存するための簡単なプログラムを実行しようとした
Iが使用Tensorflowのバージョンは、オペレーティングシステムがUbuntuの16.04であるPythonの2を使用して0.11rcあります。プログラムはJupiterのノートブックで書かれていました。
次のセッションを保存するソースコードである:
# Import TensorFlow and enable interactive sessions
import tensorflow as tf
sess = tf.InteractiveSession()
# Let's say we have a series data like this
raw_data = [1., 2., 8., -1., 0., 5.5, 6., 13.]
# Define a boolean vector called `spikes` to locate a sudden spike in raw data
spikes = tf.Variable([False] * len(raw_data), name='spikes')
# Don't forget to initialize the variable
spikes.initializer.run()
# The saver op will enable saving and restoring variables.
# If no dictionary is passed into the constructor, then the saver operators of all variables in the current program.
saver = tf.train.Saver()
# Loop through the data and update the spike variable when there is a significant increase
for i in range(1, len(raw_data)):
if raw_data[i] - raw_data[i-1] > 5:
spikes_val = spikes.eval()
spikes_val[i] = True
# Update the value of spikes by using the `tf.assign` function
updater = tf.assign(spikes, spikes_val)
# Don't forget to actually evaluate the updater, otherwise spikes will not be updated
updater.eval()
# Save the variable to the disk
save_path = saver.save(sess, "spikes.ckpt")
# Print out where the relative file path of the saved variables
print("spikes data saved in file: %s" % save_path)
# Remember to close the session after it will no longer be used
sess.close()
ディスクに「spikes.ckpt」という名前のファイルはありません。
に変数の名前を配置する必要がありspikes.ckpt'は 'のように見えますプレフィックスは実際のファイル名ではなく、実際のファイル名ではなく –
TensorFlowのバージョンによって保存形式の名前が異なります(0.11にアップグレードすると解決されますが、0.12rcに再表示されます)。それは.checkpointファイルの末尾に.DATA-00000-の-00001を追加して、今働いていない – Conchylicultor