ChromaGAN
ChromaGAN copied to clipboard
Can not train model
I'm trying to retrain the model according to the instructions in the README.md file,
python SOURCE/ChromaGAN.py
then this error appears
Traceback (most recent call last):
File "/home/yuuto/Persenal/ChromaGan/ChromaGAN/SOURCE/ChromaGAN.py", line 340, in <module>
colorizationModel.train(train_data,test_data, log)
File "/home/yuuto/Persenal/ChromaGan/ChromaGAN/SOURCE/ChromaGAN.py", line 280, in train
d_loss = self.discriminator_model.train_on_batch([trainL, trainAB, l_3], [positive_y, negative_y, dummy_y])
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/keras/engine/training.py", line 2093, in train_on_batch
logs = self.train_function(iterator)
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py", line 1147, in autograph_handler
raise e.ag_error_metadata.to_exception(e)
TypeError: in user code:
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/keras/engine/training.py", line 1021, in train_function *
return step_function(self, iterator)
File "/home/yuuto/Persenal/ChromaGan/ChromaGAN/SOURCE/ChromaGAN.py", line 82, in gradient_penalty_loss *
gradients = K.gradients(y_pred, averaged_samples)[0]
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/keras/backend.py", line 4352, in gradients **
return tf.compat.v1.gradients(
File "/home/yuuto/anaconda3/envs/Osu/lib/python3.9/site-packages/keras/engine/keras_tensor.py", line 254, in __array__
raise TypeError(
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(10, 224, 224, 2), dtype=tf.float32, name=None), name='random_weighted_average/add:0', description="created by layer 'random_weighted_average'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
What did I do wrong? I have tried running on different environments and the same phenomenon occurs. using Tensorflow 2.8.0
I have similar questions. Can we contact? This is my email [email protected]
Hi, I didn't face this problem. If you found a solution you could add it here to help others. Thanks!