fengyang0317 / unsupervised_captioning

Code for Unsupervised Image Captioning
MIT License
215 stars 51 forks source link

ValueError: No variables provided. #2

Closed songpipi closed 4 years ago

songpipi commented 5 years ago

I follow the steps strictly with tensorflow 1.13.1 and python 3.7. But when I run im_caption_full.py, I got this error. How to solve this error?

The error appears in model_fn, train_ops = tfgan.gan_train_ops( gan_model, gan_loss, generator_optimizer=gen_opt, discriminator_optimizer=dis_opt, transform_grads_fn=transform_grads_fn, summarize_gradients=is_chief, check_for_unused_update_ops=not FLAGS.use_pool, aggregation_method=tf.AggregationMethod.EXPERIMENTAL_ACCUMULATE_N)

(...)
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Traceback (most recent call last):
  File "im_caption_full.py", line 453, in <module>
    tf.app.run(main1())
  File "im_caption_full.py", line 449, in main1
    estimator.train(train_input_fn, max_steps=FLAGS.max_steps)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 358, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1124, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1154, in _train_model_default
    features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1112, in _call_model_fn
    model_fn_results = self._model_fn(features=features, **kwargs)
  File "im_caption_full.py", line 372, in model_fn
    aggregation_method=tf.AggregationMethod.EXPERIMENTAL_ACCUMULATE_N)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/contrib/gan/python/train.py", line 1012, in gan_train_ops
    **kwargs)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/contrib/training/python/training/training.py", line 458, in create_train_op
    grad_updates = optimizer.apply_gradients(grads, global_step=global_step)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 572, in apply_gradients
    raise ValueError("No variables provided.")
ValueError: No variables provided.
fengyang0317 commented 5 years ago

I am able to reproduce this error using python3. I guess it is a Tensorflow side bug. I did not encounter this error using python2.7.

Please use python2.7 instead.

ShanCao18 commented 5 years ago

I follow the steps strictly with tensorflow 1.13.1 and python 3.7. But when I run im_caption_full.py, I got this error. How to solve this error?

The error appears in model_fn, train_ops = tfgan.gan_train_ops( gan_model, gan_loss, generator_optimizer=gen_opt, discriminator_optimizer=dis_opt, transform_grads_fn=transform_grads_fn, summarize_gradients=is_chief, check_for_unused_update_ops=not FLAGS.use_pool, aggregation_method=tf.AggregationMethod.EXPERIMENTAL_ACCUMULATE_N)

(...)
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Traceback (most recent call last):
  File "im_caption_full.py", line 453, in <module>
    tf.app.run(main1())
  File "im_caption_full.py", line 449, in main1
    estimator.train(train_input_fn, max_steps=FLAGS.max_steps)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 358, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1124, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1154, in _train_model_default
    features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1112, in _call_model_fn
    model_fn_results = self._model_fn(features=features, **kwargs)
  File "im_caption_full.py", line 372, in model_fn
    aggregation_method=tf.AggregationMethod.EXPERIMENTAL_ACCUMULATE_N)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/contrib/gan/python/train.py", line 1012, in gan_train_ops
    **kwargs)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/contrib/training/python/training/training.py", line 458, in create_train_op
    grad_updates = optimizer.apply_gradients(grads, global_step=global_step)
  File "/data/songpp/anaconda2/envs/tensorflow-gpu/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 572, in apply_gradients
    raise ValueError("No variables provided.")
ValueError: No variables provided.

Hello, songpipi did you solve the problem? I want to contact you with e-mails. Can you give me your e-mail address?

songpipi commented 5 years ago

@Pearlcandy python2.7 will be ok

fengyang0317 commented 4 years ago

I have fixed this issue. I made a mistake at https://github.com/fengyang0317/unsupervised_captioning/blob/master/misc_fn.py#L47. It is not the error of TensorFlow.