tensorflow.python.framework.errors_impl.InternalError:使用wide_n_deep_tutorial.py时无法从提要中获取元素作为字节 [英] tensorflow.python.framework.errors_impl.InternalError: Unable to get element from the feed as bytes when use wide_n_deep_tutorial.py

查看:23
本文介绍了tensorflow.python.framework.errors_impl.InternalError:使用wide_n_deep_tutorial.py时无法从提要中获取元素作为字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用tensorflow官网提供的wide_n_deep_tutorial.py时,教程可以成功运行,但是我修改了数据和对应的特征后,会提示如下错误:

when I try to use wide_n_deep_tutorial.py provided by tensorflow official website, the tutorial can be run successfully, but after I change the data and corresponding feature, it will show the error below:

File "wide_n_deep_feed.py", line 224, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "wide_n_deep_feed.py", line 185, in main
    FLAGS.train_data, FLAGS.test_data)
  File "wide_n_deep_feed.py", line 166, in train_and_eval
    steps=train_steps)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 241, in train
    loss = self._train_model(input_fn=input_fn, hooks=hooks)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 686, in _train_model
    _, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 534, in __exit__
    self._close_internal(exception_type)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 569, in _close_internal
    self._sess.close()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 811, in close
    self._sess.close()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 908, in close
    ignore_live_threads=True)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
    six.reraise(*self._exc_info_to_raise)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/inputs/queues/feeding_queue_runner.py", line 94, in _run
    sess.run(enqueue_op, feed_dict=feed_dict)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 895, in run
    run_metadata_ptr)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    options, run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Unable to get element from the feed as bytes.

PS:我的模型目录中已经生成了一些文件:检查点、事件、graph.pbtxt、model.ckpt-0.data-00000-of-00001、model.ckpt-0.index、model.ckpt-0.meta

PS: there are some files generated in my models directory already: checkpoint, events, graph.pbtxt, model.ckpt-0.data-00000-of-00001,model.ckpt-0.index,model.ckpt-0.meta

任何答案将不胜感激.

推荐答案

使用带有 NaN 值的数据框时发生错误,因此 Tensorflow 无法将列转换为 tf.Dtype,您可以使用示例代码中的行:

The error occurred when you use the dataframe with NaN value, so Tensorflow can not convert the columns to tf.Dtype, you can use the line in sample code:

df_data = df_data.dropna(how="any", axis=0)

删除所有 NaN 样本,或者您可以转换数字列并将所有 NaN 值替换为空字符串,如下所示:

to remove all NaN samples or you can cast the numeric column and replace all NaN value with empty string like this:

# Cast to numeric column
df_data["numeric_column_title"] = pd.to_numeric(df_data["numeric_column_title"],errors='coerce')
# Replace NaN value with 0
df_data[["numeric_column_title1", "numeric_column_title2"]] = df_data[["numeric_column_title1", "numeric_column_title2"]].fillna(value=0)
# Replace other string columns with empty string
df_data = df_data.fillna(value='')

希望这有助于:)

这篇关于tensorflow.python.framework.errors_impl.InternalError:使用wide_n_deep_tutorial.py时无法从提要中获取元素作为字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆