トレーニングを続行するためにモデルをロードしようとしていますが、エラーが発生します
NotFoundError:TensorSliceReaderコンストラクターが失敗しました:./ drive / My Drive / DLSRL / Model /に一致するファイルが見つかりませんでした
[[ノード:save / RestoreV2_81 = RestoreV2 [dtypes = [DT_FLOAT]、_ device = "/ job:localhost / Replica:0 / task:0 / cpu:0"](_ arg_save / Const_0_0、save / RestoreV2_81 / tensor_names、save / RestoreV2_81 / shape_and_slices)]]
[[ノード:save / RestoreV2_3 / _189 = _Recvclient_terinated = false、recv_device = "/ job:localhost / reply:0 / task:0 / gpu:0"、send_device = "/ job:localhost / reply:0 / task:0 / cpu:0 "、send_device_incarnation = 1、tensor_name =" edge_396_save / RestoreV2_3 "、tensor_type = DT_FLOAT、_device =" / job:localhost / reply:0 / task:0 / gpu:0 "]]
op'save / RestoreV2_81 'が原因で、次の場所で定義されています:ファイル "/usr/lib/python3.6/runpy.py"、行193、_run_module_as_main " main "、mod_spec)
私のフォルダ構造モデルにはチェックポイントが含まれています、03-27-09-15_epoch_29.ckpt.data-00000-of-00001,03-27-09-15_epoch_29.ckpt.index、03-27-09-15_epoch_29.ckpt.meta
これがコードです
saver = tf.train.import_meta_graph('./drive/My Drive/DLSRL/Model/03-27-09-15_epoch_39.ckpt.meta')
g = tf.get_default_graph()
with g.as_default():
model = Model(config, embeddings, label_dict.size(), g)
sess = tf.Session(graph=g, config=tf.ConfigProto(allow_soft_placement=True,
log_device_placement=False))
saver.restore(sess,'./drive/My Drive/DLSRL/Model/')
#sess.run(tf.global_variables_initializer())
ckpt_saver = tf.train.Saver(max_to_keep=config.max_epochs)
for epoch in range(39,config.max_epochs):
# save chckpoint from which to load model
path = runs_dir / "{}_epoch_{}.ckpt".format(time_of_init, epoch)
ckpt_saver.save(sess, str(path))
print('Saved checkpoint.')
evaluate(dev_data, model, sess, epoch, global_step)
x1, x2, y = shuffle_stack_pad(train_data, config.train_batch_size)
epoch_start = time.time()
for x1_b, x2_b, y_b in get_batches(x1, x2, y, config.train_batch_size):
feed_dict = make_feed_dict(x1_b, x2_b, y_b, model, config.keep_prob)
if epoch_step % LOSS_INTERVAL == 0:
# tensorboard
run_options = tf.RunOptions(trace_level=tf.RunOptions.NO_TRACE)
scalar_summaries = sess.run(model.scalar_summaries,
feed_dict=feed_dict,
options=run_options)
model.train_writer.add_summary(scalar_summaries, global_step)
# print info
print("step {:>6} epoch {:>3}: loss={:1.3f}, epoch sec={:3.0f}, total hrs={:.1f}".format(
epoch_step,
epoch,
epoch_loss_sum / max(epoch_step, 1),
(time.time() - epoch_start),
(time.time() - global_start) / 3600))
loss, _ = sess.run([model.nonzero_mean_loss, model.update], feed_dict=feed_dict)
epoch_loss_sum+= loss
epoch_step += 1
global_step += 1
epoch_step = 0
epoch_loss_sum = 0.0
修正を提案してもらえますか?
復元するチェックポイントを指定していません。への変更:
saver.restore(sess, tf.train.latest_checkpoint('./drive/My Drive/DLSRL/Model/'))
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加