小编Vik*_*man的帖子

来自Dataset的tf.train.MonitoredTrainingSession和reinitializable迭代器

似乎MonitoredTrainingSession在第一次调用.run(..)之前做了一些操作(logging?),这意味着当我这样做时:

train_data = reader.traindata() # returns a tf.contrib.data.Dataset
it = tf.contrib.data.Iterator.from_structure(train_data.output_types, train_data.output_shapes)
init_train = it.make_initializer(train_data)
ne = it.get_next()
ts = tf.train.MonitoredTrainingSession(checkpoint_dir=save_path)

... no calls to ts.run ...

ts.run(init_train)
Run Code Online (Sandbox Code Playgroud)

这会产生错误:

FailedPreconditionError (see above for traceback): GetNext() failed because the iterator has not been initialized. Ensure that you have run the initializer operation for this iterator before getting the next element
Run Code Online (Sandbox Code Playgroud)

因此,在运行我提供的操作之前,它就像MonitoredTrainingSession正在执行某些操作一样接缝,从而无法使用来自Dataset的可重新初始化的迭代器进行togeather.

我相信我错过了一些东西,并希望听到:-)

tensorflow tensorflow-datasets

12
推荐指数
1
解决办法
1963
查看次数

标签 统计

tensorflow ×1

tensorflow-datasets ×1