Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ValueError: features should be a dictionary of Tensors. Given type: <class 'tensorflow.python.data.ops.dataset_ops.BatchDataset'>" #3331

Closed
puren opened this issue Feb 6, 2018 · 16 comments

Comments

@puren
Copy link

puren commented Feb 6, 2018

System information

  • What is the top-level directory of the model you are using: models/samples/core/get_started
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.4
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version: cuda 8.0, cuDNN 6
  • GPU model and memory: GeForce GTX 1050 , totalMemory: 3.95GiB freeMemory: 3.44GiB
  • Exact command to reproduce:
    (tensorflow) $ python premade_estimator.py

Describe the problem

I installed tensorflow with Virtualenv. Then, I tried to run premade_estimator.py. However I get the following error:

INFO:tensorflow:Using default config.
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmp19j387ud
INFO:tensorflow:Using config: {'_task_type': 'worker', '_master': '', '_task_id': 0, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f2c2043f748>, '_save_summary_steps': 100, '_is_chief': True, '_model_dir': '/tmp/tmp19j387ud', '_session_config': None, '_save_checkpoints_steps': None, '_service': None, '_save_checkpoints_secs': 600, '_tf_random_seed': None, '_log_step_count_steps': 100, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_num_worker_replicas': 1, '_num_ps_replicas': 0}
Traceback (most recent call last):
  File "premade_estimator.py", line 88, in <module>
    tf.app.run(main)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "premade_estimator.py", line 53, in main
    steps=args.train_steps)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 302, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 711, in _train_model
    features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 694, in _call_model_fn
    model_fn_results = self._model_fn(features=features, **kwargs)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/estimator/canned/dnn.py", line 334, in _model_fn
    config=config)
  File "/home/puren/.local/lib/python3.5/site-packages/tensorflow/python/estimator/canned/dnn.py", line 167, in _dnn_model_fn
    'Given type: {}'.format(type(features)))
ValueError: features should be a dictionary of `Tensor`s. Given type: <class 'tensorflow.python.data.ops.dataset_ops.BatchDataset'>
@robbie-cahill
Copy link

Tensorflow is out of date. Try upgrading to 1.5.

@apacha
Copy link

apacha commented Feb 8, 2018

Can confirm, that updating to TF 1.5 fixes this issue. Still - it's really ugly to have an exception in a tutorial script if you use TF 1.4 instead of the newest 1.5 version... No deprecation warning, nothing. Just a hard crash.

@jkim19
Copy link

jkim19 commented Feb 8, 2018

I saw this error too (1.4). If you don't want to (can't for some reason) upgrade to 1.5, you can correct this error in the iris_data.py eval_input_fn. Instead of return dataset, you can return dataset.make_one_shot_iterator().get_next(). The error message gives you clues, but unfortunately, it doesn't give you the exact spot to look for.

@jkim19
Copy link

jkim19 commented Feb 8, 2018

Also, I believe this issue can be closed.

@robbie-cahill
Copy link

One thing i'd suggest - update the tutorial to say minimum requirements of 1.5. It currently says 1.4.

@puren
Copy link
Author

puren commented Feb 9, 2018

Thank you for your suggestions. I will try @jkim19's suggestion. If it doesn't work, I guess I will need to upgrade TF.
@insprintorob yes I agree. I think it should be updated.

@puren puren closed this as completed Feb 9, 2018
@asabbah
Copy link

asabbah commented Feb 10, 2018

I tried @jkim19 method, but still have the same error

@newip
Copy link

newip commented Feb 11, 2018

Change the "return" does not fix it. I can only use 1.4.1 at this time. @jkim19 would you please help more further? Thanks a lot.

@jkim19
Copy link

jkim19 commented Feb 11, 2018

Hi, sorry about that. You also have to change the return of train_input_fn to dataset.make_one_shot_iterator().get_next(). Both train_input_fn and eval_input_fn need to return this rather than just dataset. I was using a local train function and forgot about that until the last couple comments. Remember this is only 1.4 and looking at the previous comments it looks like 1.5 doesn't have this issue. Good Luck! Hope this helps.

@nishanthdikkala
Copy link

Upgrading to tensorflow1.5 did not fix the issue for me. I'm using tensorflow on Windows10 (installed using pip3 and using python3.6).

@newip
Copy link

newip commented Feb 12, 2018

@jkim19 So nice. It works well for me now. That's cool. Thumbs up!

@asabbah
Copy link

asabbah commented Feb 14, 2018

@jkim19 Thanks, that works now. It gives a warning.

WARNING:tensorflow:Input graph does not contain a QueueRunner. That means predict yields forever. This is probably a mistake.
INFO:tensorflow:Restoring parameters from /tmp/tmp0m2g93x2/model.ckpt-1000.

But at least it works.

@srw-tuser
Copy link

Issue still exists in the tutorial (and I couldn't find a repo for the doc to update the version in)

@superddr
Copy link

definitely a bug.....so confused

@ghost
Copy link

ghost commented Mar 6, 2018

If you need to use TF version 1.4 you can clone the git repo as it instructs in the tutorial and then checkout version 1.4.0. The scripts then work as advertised, eg:

[ruser@node442 models]$ git tag
v.1.6.0
v1.4.0
[ruser@node442 models]$ git checkout v1.4.0

Then run the premade and other example python scripts. Hope this helps.

@borrascador
Copy link

This issue still exists for me. I cloned the example code just today, and I am also using tensorflow 1.4.0

Honest question: how am I supposed to learn how to use tensorflow if the example code is broken? Feeling very discouraged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants