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.