Got TypeError: cannot convert dictionary update sequence element #0 to a sequence when creating resnet network
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.
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
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))
@jrabary @parvizp which version of tensorflow and the models repo are you using?
If installed from binary pip package, provide:
- A link to the pip package you installed:
- The output from
python -c "import tensorflow; print(tensorflow.__version__)".
If installed from source, provide
- The commit hash (
git rev-parse HEAD) - The output of
bazel version
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
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 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 ?
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
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".
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.
@jrabary I have the same problem,--model_name= resnet_v1_50 or 101 152. Did you solved it?
The reason is due to the version of CUDA. please try CUDA 8.0. @qiulp @jrabary
Closing due to inactivity. Please comment with new information and I will reopen.