Models: [models/slim] Dataset class instance issue

Created on 7 Sep 2016  路  11Comments  路  Source: tensorflow/models

Hi, i'm the beginner in DL. I have some issues from slim. I want to train provided model in my desktop (cifiar10, mnist, ...).

I tried to run with shell script which provided. ("models/slim/scripts/*.sh)

But, error occurred

TypeError: new() got an unexpected keyword argument 'labels_to_names'

also for 'num_classes'

above error comes form cifar10.py line 97, 98. Also for other training python codes too.

I followed TF source code at 'contrib/slim/python/slim/data/dataset.py'. But the Datatset class has no attribute for 'num_classes' and 'labels_to_names' (TF version -> pip show tesorflow -> 0.10.0rc0, and I installed and upgrade *.whl from sim/README.md)

How can I fix it? and sorry for my shortage in English.

awaiting response

Most helpful comment

Yeah you need the nightly version of TensorFlow

All 11 comments

Please cut-and-paste the exact command that you ran, along with the full output including the error. Also which OS / architecture are you running? Thanks!

@tatatodd

My OS/architecture is described at below picture. For this machine, only Ubuntu OS was installed.

os_architecture

CUDA toolkit version: 7.5
cuDNN version: v4

Python 2.7 with Anaconda2 and my TF version is

(tensorflow) jonghoon@JHK-PC:~/projects/GitHub/models/slim$ pip show tensorflow
---
Metadata-Version: 2.0
Name: tensorflow
Version: 0.10.0rc0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
Installer: pip
License: Apache 2.0
Location: /home/jonghoon/anaconda2/envs/tensorflow/lib/python2.7/site-packages
Requires: numpy, mock, protobuf, wheel, six
Classifiers:
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  Intended Audience :: Education
  Intended Audience :: Science/Research
  License :: OSI Approved :: Apache Software License
  Programming Language :: Python :: 2.7
  Topic :: Scientific/Engineering :: Mathematics
  Topic :: Software Development :: Libraries :: Python Modules
  Topic :: Software Development :: Libraries
Entry-points:
  [console_scripts]
  tensorboard = tensorflow.tensorboard.tensorboard:main

And the error message from my desktop is

(tensorflow) jonghoon@JHK-PC:~/projects/GitHub/models/slim$ ./scripts/train_cifarnet_on_cifar10.sh 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
Dataset files already exist. Exiting without re-creating them.
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
  File "train_image_classifier.py", line 585, in <module>
    tf.app.run()
  File "/home/jonghoon/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "train_image_classifier.py", line 415, in main
    FLAGS.dataset_name, FLAGS.dataset_split_name, FLAGS.dataset_dir)
  File "/home/jonghoon/projects/GitHub/models/slim/datasets/dataset_factory.py", line 57, in get_dataset
    reader)
  File "/home/jonghoon/projects/GitHub/models/slim/datasets/cifar10.py", line 98, in get_split
    labels_to_names=labels_to_names)
TypeError: __new__() got an unexpected keyword argument 'labels_to_names'
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
  File "eval_image_classifier.py", line 191, in <module>
    tf.app.run()
  File "/home/jonghoon/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "eval_image_classifier.py", line 97, in main
    FLAGS.dataset_name, FLAGS.dataset_split_name, FLAGS.dataset_dir)
  File "/home/jonghoon/projects/GitHub/models/slim/datasets/dataset_factory.py", line 57, in get_dataset
    reader)
  File "/home/jonghoon/projects/GitHub/models/slim/datasets/cifar10.py", line 98, in get_split
    labels_to_names=labels_to_names)
TypeError: __new__() got an unexpected keyword argument 'labels_to_names'
(tensorflow) jonghoon@JHK-PC:~/projects/GitHub/models/slim$ 

Thanks!

I think your version of the tensorflow models repository under /home/jonghoon/projects/GitHub/models is out-of-sync with your version of tensorflow that you pip-installed under /home/jonghoon/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow

How did you get or install the code under /home/jonghoon/projects/GitHub/models? You might try updating to a later version of this code.

Can you cut-and-paste the output of the following commands:

$ cd /home/jonghoon/projects/GitHub/models
$ git rev-parse HEAD

@tatatodd

I installed models repository by git clone command

This is my command result from your request

jonghoon@JHK-PC:~/projects/GitHub/models$ git rev-parse HEAD
cdaa9b23d27dfa85b9b5cd98b325a42b5ca6ab43
jonghoon@JHK-PC:~/projects/GitHub/models$ 

Yes, the issue is definitely that your version of tensorflow that you pip-installed is too old.

You have tensorflow 0.10.0rc0 installed, but you need something slightly newer. You can try installing the 0.10 release, which hasn't been officially announced yet, but is very close:
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#pip-installation

Let me know how that goes. Thanks!

@tatatodd

I've re-installed and upgrade tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl from
https://github.com/tensorflow/tensorflow/tree/v0.10.0rc0 here

This also not worked so, i've built tensorflow from source using https://github.com/tensorflow/tensorflow/releases/tag/v0.10.0rc0 release version.

But both two of not work properly. Error comes with same as the log i've mentioned above

Thanks!

I've tested 0.10.0rc0 as well as r0.10. But there is same error
'TypeError: new() got an unexpected keyword argument 'labels_to_names'
Maybe should it be nightly version of tensorflow?
https://github.com/tensorflow/models/blob/master/slim/README.md

Yeah you need the nightly version of TensorFlow

i have installed tensorflow step by step from this https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup

and i have test on my mac os. the same error output. How i can solve it.

And another problem, in the master version ,the api in https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup link tell me that the tf.name_scope have 3 arguments ,but in my ipython environment ,i type "tf.name_scope?" it tell me that it has just 1 argument, .. so i am sure something wrong of my tensorflow version.

Sorry, I gave some bad advice above.

As @jjsong and @sguada say, you actually need the nightly version of TensorFlow. Instructions are here:
https://github.com/tensorflow/models/blob/master/slim/README.md#Install

@tatatodd @jjsong @sguada

Thanks very much! I resolved this problem

Was this page helpful?
0 / 5 - 0 ratings