Я пытался сохранить сеанс в модели, чтобы я мог использовать его позже, но каждый раз получаю сообщение об ошибке. Мой код выглядит так:
with tf.Session() as sess:
sess.run(init)
for j in range(3):
for i in range(xtest.shape[0]):
_, indices = sess.run(pred, feed_dict={x_train: xtrain, x_test: xtest[i,:]})
pred_label = getMajorityPredictions(ytrain, indices)
actual_val = get_char( int( (ytest[i]).argmax() ) )
# print("test: ", i, "prediction: ", get_char(pred_label), " actual: ", actual_val)
# print(pred_label, actual_val, type(pred_label), type(actual_val), sep=" --> ")
if get_char(pred_label) == actual_val:
accuracy += 1/len(xtest)
# print((i / (xtest.shape[0])) * 100)
# os.system("cls")
print("accuracy: ",accuracy)
savedPath = saver.save(sess, "/tmp/model.ckpt")
print("Model saved at: " ,savedPath)
и ошибка такая:
Traceback (most recent call last):
File "prac3.py", line 74, in <module>
saver = tf.train.Saver()
File "C:\Python36\lib\site-packages\tensorflow\python\training\saver.py", line 1239, in __init__
self.build()
File "C:\Python36\lib\site-packages\tensorflow\python\training\saver.py", line 1248, in build
self._build(self._filename, build_save=True, build_restore=True)
File "C:\Python36\lib\site-packages\tensorflow\python\training\saver.py", line 1272, in _build
raise ValueError("No variables to save")
ValueError: No variables to save