4

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: 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

Any answers will be appreciated.

1 Answer 1

3

EDIT:

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)

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='')

Hope this help :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.