Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not train model #15

Open
superhighlevel opened this issue Mar 26, 2022 · 2 comments
Open

Can not train model #15

superhighlevel opened this issue Mar 26, 2022 · 2 comments

Comments

@superhighlevel
Copy link

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

@superhighlevel superhighlevel changed the title Can't not train model Can not train model Mar 26, 2022
@wangxinlei777
Copy link

I have similar questions. Can we contact? This is my email xlwang.xidian@gmail.com

@pvitoria
Copy link
Owner

Hi,
I didn't face this problem.
If you found a solution you could add it here to help others. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants