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

Error while Running test.py and clswgan.py file #2

Open
priyank200 opened this issue Dec 5, 2023 · 0 comments
Open

Error while Running test.py and clswgan.py file #2

priyank200 opened this issue Dec 5, 2023 · 0 comments

Comments

@priyank200
Copy link

Helle @ShayanRamazi, While running the test.py file I am facing an error, can you help me with this

error:
Traceback (most recent call last):
File "c:\kush\BTP\f-CLSWGAN\test.py", line 3, in
wgan.train(epochs=30000, batch_size=1024, sample_interval=10)
File "c:\kush\BTP\f-CLSWGAN\CLSWGAN.py", line 115, in train
d_loss = self.critic_model.train_on_batch([features, labels, noise], [valid, fake, dummy])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 2787, in train_on_batch
logs = self.train_function(iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\priya\AppData\Local\Temp_autograph_generated_filep8p_9d2q.py", line 15, in tf__train_function
retval
= ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 1384, in step_function
outputs = model.distribute_strategy.run(run_step, args=(data,))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 1373, in run_step
outputs = model.train_step(data)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 1151, in train_step
loss = self.compute_loss(x, y, y_pred, sample_weight)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 1209, in compute_loss
return self.compiled_loss(
^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\compile_utils.py", line 277, in call
loss_value = loss_obj(y_t, y_p, sample_weight=sw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\losses.py", line 143, in call
losses = call_fn(y_true, y_pred)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\losses.py", line 270, in call
return ag_fn(y_true, y_pred, **self.fn_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\priya\AppData\Local\Temp_autograph_generated_filehzbehghn.py", line 14, in tf__gradient_penalty_loss
gradients = ag
.converted_call(ag__.ld(compute_gradients), (ag_.ld(y_pred), [ag__.ld(averaged_samples)]), None, fscope)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\priya\AppData\Local\Temp_autograph_generated_filerpgyuifg.py", line 11, in tf___compute_gradients
grads = ag
_.converted_call(ag__.ld(tf).gradients, (ag__.ld(tensor), ag__.ld(var_list)), None, fscope)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\keras_tensor.py", line 285, in array
raise TypeError(
TypeError: in user code:

File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\training.py", line 1401, in train_function  *
    return step_function(self, iterator)
File "c:\kush\BTP\f-CLSWGAN\LossFunctions.py", line 25, in gradient_penalty_loss  *
    gradients = _compute_gradients(y_pred, [averaged_samples])[0]
File "c:\kush\BTP\f-CLSWGAN\LossFunctions.py", line 14, in _compute_gradients  *
    grads = tf.gradients(tensor, var_list)
File "C:\kush\BTP\f-clswgan\clswgan\Lib\site-packages\keras\src\engine\keras_tensor.py", line 285, in __array__
    raise TypeError(

TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(1024, 2048), dtype=tf.float32, name=None), name='random_weighted_average/add:0', description="created by layer 'random_weighted_average'"), an intermediate Kentermediate 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 supalls that *do*ports 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 opera `call` and cation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
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

1 participant