bstriner / keras-adversarial

Keras Generative Adversarial Networks
MIT License
867 stars 231 forks source link

Variable batchnormalization_1_running_mean/biased already exists, disallowed. #8

Open manuelepalmeri opened 7 years ago

manuelepalmeri commented 7 years ago

if I try to exec "example_gan.py" I have the following error:

Traceback (most recent call last):
  File "/Users/manuelepalmeri/Downloads/keras-adversarial-master/example_gan.py", line 142, in <module>
    main()
  File "/Users/manuelepalmeri/Downloads/keras-adversarial-master/example_gan.py", line 138, in main
    latent_dim=latent_dim)
  File "/Users/manuelepalmeri/Downloads/keras-adversarial-master/example_gan.py", line 82, in example_gan
    gan = simple_gan(generator, discriminator, normal_latent_sampling((latent_dim,)))
  File "/Users/manuelepalmeri/Downloads/keras-adversarial-master/keras_adversarial/adversarial_utils.py", line 38, in simple_gan
    gan = build_gan(generator, discriminator)
  File "/Users/manuelepalmeri/Downloads/keras-adversarial-master/keras_adversarial/adversarial_utils.py", line 17, in build_gan
    yfake = Activation("linear", name="yfake")(discriminator(generator(generator.inputs)))
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 517, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 571, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 155, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/Library/Python/2.7/site-packages/keras/models.py", line 378, in call
    return self.model.call(x, mask)
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 2075, in call
    output_tensors, output_masks, output_shapes = self.run_internal_graph(inputs, masks)
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 2217, in run_internal_graph
    output_tensors = to_list(layer.call(computed_tensor, computed_mask))
  File "/Library/Python/2.7/site-packages/keras/layers/normalization.py", line 128, in call
    self.add_updates([K.moving_average_update(self.running_mean, mean, self.momentum),
  File "/Library/Python/2.7/site-packages/keras/backend/tensorflow_backend.py", line 364, in moving_average_update
    variable, value, momentum)
  File "/Library/Python/2.7/site-packages/tensorflow/python/training/moving_averages.py", line 70, in assign_moving_average
    update_delta = _zero_debias(variable, value, decay)
  File "/Library/Python/2.7/site-packages/tensorflow/python/training/moving_averages.py", line 177, in _zero_debias
    trainable=False)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1024, in get_variable
    custom_getter=custom_getter)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 850, in get_variable
    custom_getter=custom_getter)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 346, in get_variable
    validate_shape=validate_shape)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 331, in _true_getter
    caching_device=caching_device, validate_shape=validate_shape)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 632, in _get_single_variable
    name, "".join(traceback.format_list(tb))))
ValueError: Variable batchnormalization_1_running_mean/biased already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:

  File "/Library/Python/2.7/site-packages/keras/backend/tensorflow_backend.py", line 364, in moving_average_update
    variable, value, momentum)
  File "/Library/Python/2.7/site-packages/keras/layers/normalization.py", line 128, in call
    self.add_updates([K.moving_average_update(self.running_mean, mean, self.momentum),
  File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 155, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))

can someone help me?

bstriner commented 7 years ago

Hi @manuelepalmeri . Might be some issues on tensorflow that I haven't been testing until recently. Just worked through a lot of keras compatibility issues. Some weirdness with batchnormalization in GANs. The current master version of example_gan should be working fine. Please let me know if you have issues with that script after an update.

Cheers

zeka0 commented 6 years ago

I encountered the same problem today in tensorflow 1.2 and keras newest version. But in tensorflow 1.6 it works as intended.

serser commented 6 years ago

As in my case, this error disappears when I upgraded to tf 1.7 and keras 2.1.5.