我不知道如何在ubuntutensorflowgpu上做到这一点,“E tensorflow/core/util/events_作家.cc: 104]

2024-04-25 17:19:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要写一个关于这个深度学习问题的检查点。但是这个错误阻止了我写文件。(E:在tf.summary.FileWriter文件)你知道吗

错误: “tensorflow/core/util/events”_作者:抄送: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_作者:抄送:104]写入失败,因为无法打开文件。你知道吗

ValueError:传递的save\u路径不是有效的检查点:./modelckpt/开始.ckpt你知道吗

tensorflow gpu版本为1.10.0。 python版本是3.5(我认为)。 我已经安装了张力板。你知道吗


Tags: 文件coretesttftensorflowdirutiltrain
1条回答
网友
1楼 · 发布于 2024-04-25 17:19:22

基本上,该错误表示检查点文件不存在,因此它不是有效的检查点。你知道吗

在执行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")

请在下面的链接https://github.com/tensorflow/docs/blob/master/site/en/r1/guide/saved_model.md中参考Tensorflow版本1.x的保存和还原说明和代码

相关问题 更多 >