google-research / mixmatch

Apache License 2.0
1.13k stars 163 forks source link

ValueError: Tensor("buffer_size:0", shape=(), dtype=int64) must be from the same graph as Tensor("ParallelMapDataset:0", shape=(), dtype=variant). #4

Closed zhangbin0917 closed 5 years ago

zhangbin0917 commented 5 years ago

Very thanks for your code! I meet ValueError when i run python pseudo_label.py --train_dir experiments/compare --dataset=cifar10.1@250-1 --wd=0.02 --smoothing=0.01 --consistency_weight=1

Traceback (most recent call last): File "pseudo_label.py", line 130, in app.run(main) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run _run_main(main, args) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "pseudo_label.py", line 93, in main dataset = data.DATASETS[FLAGS.dataset]() File "/mnt/SSD/ssl/mixmatch/libml/data.py", line 171, in create train_labeled=fn(train_labeled).map(augment[0], para), File "/mnt/SSD/ssl/mixmatch/libml/data.py", line 67, in memoize dataset = dataset.prefetch(16) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 1777, in prefetch return DatasetV1Adapter(super(DatasetV1, self).prefetch(buffer_size)) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 721, in prefetch return PrefetchDataset(self, buffer_size) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 3503, in init **flat_structure(self)) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/gen_dataset_ops.py", line 4297, in prefetch_dataset slack_period=slack_period, name=name) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/op_def_library.py", line 366, in _apply_op_helper g = ops._get_graph_from_inputs(_Flatten(keywords.values())) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 5885, in _get_graph_from_inputs _assert_same_graph(original_graph_element, graph_element) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 5821, in _assert_same_graph (item, original_item)) ValueError: Tensor("buffer_size:0", shape=(), dtype=int64) must be from the same graph as Tensor("ParallelMapDataset:0", shape=(), dtype=variant).

david-berthelot commented 5 years ago

What TensorFlow version is it happening on? During development we used 1.12.0

zhangbin0917 commented 5 years ago

My TensorFlow version is 1.14.0. And I also want to ask how many iterations in training process? I am a bit confused about you code. It's seem to the number of iteration in your implement is not same to the paper "Realistic evaluation of deep semi-supervised learning algorithms" (500,000 iterations).

david-berthelot commented 5 years ago

So try

pip install tensorflow-gpu==1.12.0

As to the iteration, this code counts them in number of images seen. For standard experiments, the number is 64 million roughly speaking. So in terms of iterations, the number would be divided by the batch size (64).

Yes there are many difference with the paper you mentioned, amongst them we also do not use a learning rate schedule, we also use less augmentations (just mirror and shift) to keep things simpler.

zhangbin0917 commented 5 years ago

I know, I will try tensorflow with 1.12.0. Thank you for your reply.

david-berthelot commented 5 years ago

I also pushed a commit to the requirements.txt file so that it install 1.12.0 by default.

varunnair18 commented 5 years ago

Did you have any success with making pseudo_label.py run @zhangbin0917 ? I am having a similar error while running mixup.py, vat.py, and pseudo_label.py, however, I am able to successfully run mixmatch.py, ict.py, and mean_teacher.py .

ValueError: Cannot feed value of shape (64, 2, 32, 32, 3) for Tensor 'y:0', which has shape '(?, 32, 32, 3)'

This is using version 1.13.1 of tensorflow.

jagielski commented 5 years ago

That's a different issue - the problem there is the placeholder y_in (line 43 in mixup.py, 37 in vat.py, and 36 in pseudo_label.py) has the wrong shape: [None] + hwc, when the ClassifySemi code passes in [None, 2] + hwc A quick fix might be changing the y_in line to y_in = tf.placeholder(tf.float32, [None, 2] + hwc, 'y') y_stacked = tf.reshape(y_in, [-1] + hwc) and then changing logits_y = classifier(y_in, training=True) to logits_y = classifier(y_stacked, training=True) in the relevant files, but I'm not sure that follows intended behavior of the respective algorithms.