【问题标题】:I don't know how to do this at ubuntu tensorflow-gpu, "E tensorflow / core / util / events_writer.cc: 104]我不知道如何在 ubuntu tensorflow-gpu 上执行此操作,“E tensorflow / core / util / events_writer.cc: 104]
【发布时间】:2020-01-03 18:18:03
【问题描述】:

我需要为这个深度学习问题写一个检查点。但是那个错误阻止我写文件。 (E:在 tf.summary.FileWriter)

错误: "tensorflow/core/util/events_writer.cc:104] 写入失败,因为文件无法打开。

我试过这个。重装、删除、授权(tensorflow-gpu、tensorflow、tensorboard)

with tf.Session() as sess:
    dir = pickledir
    dic_0 = pat_level_arr(dir, 0, [0, 1])
    dic_1 = pat_level_arr(dir, 1, [1, 0])

    seed = 42
    abc = range(len(dic_0))
    abcd = range(len(dic_1))

    dic_0_train, dic_0_test, _, _ = train_test_split(
        dic_0, abc, test_size=0.244, random_state=seed)
    dic_1_train, dic_1_test, _, _ = train_test_split(
        dic_1, abcd, test_size=0.35, random_state=seed)

    dic_train = np.concatenate((dic_0_train, dic_1_train), axis=0)
    dic_test = np.concatenate((dic_0_test, dic_1_test), axis=0)
    summaries_dir = './logs_level'
#here is the problem "tensorflow/core/util/events_writer.cc:104] Write failed because file could not be opened.
======================================================================
    print("here is start\n")
    train_writer = tf.summary.FileWriter(summaries_dir + '/train', sess.graph)
    test_writer = tf.summary.FileWriter(summaries_dir + '/test')
    print("here is end\n")
======================================================================
    init = tf.global_variables_initializer()
    sess.run(init)

    # For train
    try:
        saver.restore(sess, './modelckpt/inception.ckpt')
        print('Model restored')
        epoch_saved = data_saved['var_epoch_saved'].eval()
    except tf.errors.NotFoundError:
        print('No saved model found')
        epoch_saved = 1
    except tf.errors.InvalidArgumentError:
        print('Model structure has change. Rebuild model')
        epoch_saved = 1

E tensorflow/core/util/events_writer.cc:104] 写入失败,因为文件无法打开。

ValueError : 传递的 save_path 不是有效的检查点:./modelckpt/inception.ckpt

tensorflow-gpu 版本为 1.10.0。 python版本是3.5(我认为)。 我已经安装了张量板。

【问题讨论】:

  • 以前从未见过,您的文件系统中是否已有文件夹?
  • 您在尝试恢复之前是否先保存/创建了检查点?
  • 这里的问题不是作者,而是你加载 Tensorflow 模型的方式。您可以通过此基本教程阅读本教程,并检查您遵循的步骤是否符合本教程。您也可以参考以下How to Answer (github.com/tensorflow/tensorflow/issues/…),如果有帮助请告诉我。

标签: python tensorflow ubuntu


【解决方案1】:

基本上,错误表明检查点文件不存在,因此它不是有效的检查点。

您需要使用以下代码保存模型在执行saver.restore() 方法之前,因为它会从磁盘加载文件。

saver = tf.train.Saver()
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")

请参阅以下链接中的 Tensorflow 版本 1.x 的保存和恢复说明和代码,https://github.com/tensorflow/docs/blob/master/site/en/r1/guide/saved_model.md

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-08
    • 1970-01-01
    • 2018-06-09
    • 2021-10-16
    • 2019-06-04
    • 2019-01-03
    • 2020-10-21
    • 1970-01-01
    相关资源
    最近更新 更多