簡體   English   中英

如何存儲/保存和恢復tensorflow DNNClassifier(無變量保存)

[英]how to store/save and restore tensorflow DNNClassifier(No variables to save)

我在tensorflow上訓練了一個深度神經網絡並用來預測一些例子但是,當我嘗試使用train.Saver()保存它時,我得到錯誤:“沒有要保存的變量”

已經嘗試過train.Saver這樣:

tf.train.Saver(classi.get_variable_names())

但仍然沒有運氣,有什么建議嗎?

所以我遇到了同樣的問題(Estimators還沒有保存/恢復功能)。 我試過保存和CheckpointSaver試圖保存檢查點,但事實證明它更簡單; 只需在實例化Estimator時指定model_dir 這將通過創建具有相同model_dir的Estimator自動保存可以恢復的檢查點。 這里有Estimators的文檔。

由於@ilblackdragon該解決方案在這里

以下是來自tf.variable文檔的代碼示例,可能會澄清:

# Create some variables.
v1 = tf.Variable(..., name="v1")
v2 = tf.Variable(..., name="v2")
...
# Add an op to initialize the variables.
init_op = tf.initialize_all_variables()

# Add ops to save and restore all the variables.
saver = tf.train.Saver()

# Later, launch the model, initialize the variables, do some work, save the
# variables to disk.
with tf.Session() as sess:
  sess.run(init_op)
  # Do some work with the model.
  ..
  # Save the variables to disk.
  save_path = saver.save(sess, "/tmp/model.ckpt")
  print("Model saved in file: %s" % save_path)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM