models icon indicating copy to clipboard operation
models copied to clipboard

Got TypeError: cannot convert dictionary update sequence element #0 to a sequence when creating resnet network

Open jrabary opened this issue 10 years ago • 12 comments

When I'm trying to create a resnet network (e.g v1_50) I got the following error

TypeError: cannot convert dictionary update sequence element #0 to a sequence

I suspect that this is due to the following line

# Convert end_points_collection into a dictionary of end_points.
end_points = dict(tf.get_collection(end_points_collection))

in the resnet_v1.py file.

jrabary avatar Sep 26 '16 10:09 jrabary

This appears to be happening on multiple networks. The AlexNet tests fail as well:

======================================================================
ERROR: testBuild (__main__.AlexnetV2Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/2TB/Git/tfslim/models/slim/bazel-bin/alexnet_test.runfiles/slim/nets/alexnet_test.py", line 35, in testBuild
    logits, _ = alexnet.alexnet_v2(inputs, num_classes)
  File "/mnt/2TB/Git/tfslim/models/slim/bazel-bin/alexnet_test.runfiles/slim/nets/alexnet.py", line 120, in alexnet_v2
    end_points = dict(tf.get_collection(end_points_collection))
TypeError: cannot convert dictionary update sequence element #0 to a sequence

parvizp avatar Sep 27 '16 17:09 parvizp

I had the same problem, I simply changed this line for end_points = dict((v.name,v) for v in tf.get_collection(end_points_collection))

Hediby avatar Sep 28 '16 08:09 Hediby

@jrabary @parvizp which version of tensorflow and the models repo are you using?

If installed from binary pip package, provide:

  1. A link to the pip package you installed:
  2. The output from python -c "import tensorflow; print(tensorflow.__version__)".

If installed from source, provide

  1. The commit hash (git rev-parse HEAD)
  2. The output of bazel version

tatatodd avatar Oct 07 '16 01:10 tatatodd

Simply using " end_points = dict((v.name,v) for v in tf.get_collection(end_points_collection)) " can solve this problem ? @Hediby

In my experiment, some errors related to Histogram prompted when I try to train the vgg or resnet on imagenet dataset: InvalidArgumentError (see above for traceback): Nan in summary histogram for: HistogramSummary_22

gclouding avatar Oct 12 '16 05:10 gclouding

I can't find where I originally found this code, but it works for me:

end_points = slim.utils.convert_collection_to_dict(end_points_collection)

Edit: Ah, it was here, under the main tensorflow repository: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/slim/python/slim/nets/vgg.py

vonclites avatar Oct 12 '16 23:10 vonclites

@vonclites I tried your code "end_points = slim.utils.convert_collection_to_dict(end_points_collection)", and it printed the following errors:

INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors.InvalidArgumentError'>, Nan in summary histogram for: HistogramSummary_13 [[Node: HistogramSummary_13 = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](HistogramSummary_13/tag, vgg_16/fc8/squeezed/_427)]] [[Node: HistogramSummary_8 = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](HistogramSummary_8/tag, vgg_16/conv3/conv3_2/Relu/_375)]]

May I know how you installed the tensorflow (./configure info) and which version of tensorflow are you using ?

gclouding avatar Oct 13 '16 01:10 gclouding

Sure. Using Python 3.5.2. TF 11.0rc0 CUDA 7.5 (I know it also works with CUDA 8.0) Installed via pip using https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64.whl

vonclites avatar Oct 13 '16 01:10 vonclites

I also tried https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64.whl @vonclites Are you using finetune or training from scatch ? I am using finetuning with the following command: python train_image_classifier.py
--train_dir=${TRAIN_DIR}
--dataset_name=${DATA_NAME}
--dataset_split_name=train
--dataset_dir=${DATASET_DIR}
--model_name=vgg_16
--checkpoint_path=${PRETRAINED_CHECKPOINT_DIR}/vgg_16.ckpt
--max_number_of_steps=10000
--batch_size=16
--learning_rate=0.01
--learning_rate_decay_type=fixed
--save_interval_secs=600
--save_summaries_secs=600
--log_every_n_steps=100
--optimizer=rmsprop
--weight_decay=0.00004
--labels_offset=1

However, no errors prompted, but it printed no info: INFO:tensorflow:Starting Session. INFO:tensorflow:Starting Queues. INFO:tensorflow:global_step/sec: 0

After waiting for more than ten mniutes, still no info printed. But I can see that GPU is always busy with computation (GPU-util is 99% ) using the command "watch -n 0.1 nvidia-smi".

gclouding avatar Oct 13 '16 02:10 gclouding

I was training from scratch on cifar10. However, the cifar10 dataset has its own compatibility issues with python3 (https://github.com/tensorflow/models/pull/408) ... so I had to deal with those first. I'm not at my pc or I would try vgg, sorry.

vonclites avatar Oct 13 '16 02:10 vonclites

@jrabary I have the same problem,--model_name= resnet_v1_50 or 101 152. Did you solved it?

lupingqiu avatar Oct 18 '16 10:10 lupingqiu

The reason is due to the version of CUDA. please try CUDA 8.0. @qiulp @jrabary

gclouding avatar Oct 18 '16 10:10 gclouding

Closing due to inactivity. Please comment with new information and I will reopen.

aselle avatar Oct 31 '16 21:10 aselle