tensorflow.python.framework.errors\u impl.InternalError:使用wide\n\u deep\u tutorial.py时,无法从提要中获取作为字节的元素
当我尝试使用tensorflow官网提供的wide_n_deep_tutorial.py时,教程可以成功运行,但在我更改数据和相应功能后,它会显示以下错误:tensorflow.python.framework.errors\u impl.InternalError:使用wide\n\u deep\u tutorial.py时,无法从提要中获取作为字节的元素,python,tensorflow,Python,Tensorflow,当我尝试使用tensorflow官网提供的wide_n_deep_tutorial.py时,教程可以成功运行,但在我更改数据和相应功能后,它会显示以下错误: 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/platf
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.
文件“宽\u n\u深\u feed.py”,第224行,在
tf.app.run(main=main,argv=[sys.argv[0]]]+未解析)
文件“/usr/lib/python2.7/site packages/tensorflow/python/platform/app.py”,第48行,正在运行
_系统出口(主(_sys.argv[:1]+标志_passthrough))
文件“wide\u n\u deep\u feed.py”,第185行,在main中
FLAGS.train_数据、FLAGS.test_数据)
列和评估中的第166行文件“宽\u n\u深\u feed.py”
步数=列车步数)
文件“/usr/lib/python2.7/site packages/tensorflow/python/estimator/estimator.py”,第241行,列车中
损耗=自身。\列车\模型(输入\ fn=输入\ fn,挂钩=挂钩)
文件“/usr/lib/python2.7/site packages/tensorflow/python/estimator/estimator.py”,第686行,列车模型
_,损失=一次运行([estimator\u spec.train\u op,estimator\u spec.loss])
文件“/usr/lib/python2.7/site packages/tensorflow/python/training/monitored_session.py”,第534行,在退出时__
自我关闭内部(例外类型)
文件“/usr/lib/python2.7/site packages/tensorflow/python/training/monitored_session.py”,第569行,在内部关闭
self.\u sess.close()
文件“/usr/lib/python2.7/site packages/tensorflow/python/training/monitored_session.py”,第811行,关闭
self.\u sess.close()
文件“/usr/lib/python2.7/site packages/tensorflow/python/training/monitored_session.py”,第908行,关闭
忽略(实时线程=真)
文件“/usr/lib/python2.7/site packages/tensorflow/python/training/coordinator.py”,第389行,在join中
六、重新提升(*自我执行信息提升)
文件“/usr/lib/python2.7/site packages/tensorflow/python/estimator/inputs/queues/feeding\u queue\u runner.py”,第94行,in\u run
sess.run(排队运行,提要dict=提要dict)
文件“/usr/lib/python2.7/site packages/tensorflow/python/client/session.py”,第895行,正在运行
运行_元数据_ptr)
文件“/usr/lib/python2.7/site packages/tensorflow/python/client/session.py”,第1124行,正在运行
feed_dict_tensor、options、run_元数据)
文件“/usr/lib/python2.7/site packages/tensorflow/python/client/session.py”,第1321行,运行
选项,运行(元数据)
文件“/usr/lib/python2.7/site packages/tensorflow/python/client/session.py”,第1340行,在
提升类型(e)(节点定义、操作、消息)
tensorflow.python.framework.errors\u impl.InternalError:无法从提要中获取作为字节的元素。
PS:我的模型目录中已经生成了一些文件:
检查点,事件,graph.pbtxt,model.ckpt-0.data-00000-of-00001,model.ckpt-0.index,model.ckpt-0.meta
任何答案都将不胜感激。编辑:
使用带有NaN值的dataframe时出错,因此Tensorflow无法将列转换为tf.Dtype,您可以使用示例代码中的行:
df_data = df_data.dropna(how="any", axis=0)
要删除所有NaN样本,或者可以强制转换数值列,并用空字符串替换所有NaN值,如下所示:
# 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='')
希望这有帮助:)