FailedPreconditionError: GetNext() failed because the iterator has not been initialized in Tensorflow 2.3

徘徊边缘 提交于 2021-01-29 22:08:12

问题


Why do I get dataset not initialized error in Tensorflow 2.3 where there is no longer a concept of session?

import tensorflow as tf

print(tf.__version__)

bm = tf.estimator.BaselineRegressor(
    model_dir=None, label_dimension=1, weight_column=None, optimizer='Ftrl',
)

def create_dummy_data():
    d = tf.data.Dataset.from_generator(lambda:
                                           iter(
  ({'osName': b'Android OS', 'osVersion': b'5.1.1',
    'deviceModel': b'dfjhgsdjhfshfjsgdjhf'}, 100),
  ...
                                           ),
                                           output_types=({
                                               "osName": tf.string,
                                               "osVersion": tf.string,
                                               "deviceModel": tf.string
                                           }, tf.int32))
    return d

# input_fns = DataInputFns()
bm.train(
    create_dummy_data,
    steps=6
)

Pasted the entire code at https://colab.research.google.com/drive/1HlZ0NLbu5tZu0HfQvvPIrDx6Um2WVRLc?usp=sharing

来源:https://stackoverflow.com/questions/64094061/failedpreconditionerror-getnext-failed-because-the-iterator-has-not-been-init

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!