Skip to content

expects 1 input(s), but it received 2 input tensors #3

@EveraertJan

Description

@EveraertJan

Hi,

Love the video's, I'm learning a lot. However, I tried to combine the video about fashionGAN, and the one about imageClassification with a custom dataset. I'm getting the following error, and I'm wondering if I need to dive deeper into the technicalities, or if I'm just missing something.


---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-61-b0f21fd11f47> in <cell line: 4>()
      2 # data = ds.as_numpy_iterator()
      3 
----> 4 hist = fashgan.fit(train, epochs=1, callbacks=[ModelMonitor()])

1 frames

/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
   1145           except Exception as e:  # pylint:disable=broad-except
   1146             if hasattr(e, "ag_error_metadata"):
-> 1147               raise e.ag_error_metadata.to_exception(e)
   1148             else:
   1149               raise

ValueError: in user code:

    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1021, in train_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1010, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1000, in run_step  **
        outputs = model.train_step(data)
    File "<ipython-input-31-1f21f98ff43d>", line 29, in train_step
        yhat_real = self.discriminator(real_images, training=True)
    File "/usr/local/lib/python3.10/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/input_spec.py", line 200, in assert_input_compatibility
        raise ValueError(f'Layer "{layer_name}" expects {len(input_spec)} input(s),'

    ValueError: Layer "sequential_1" expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, 256, 256, 1) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None,) dtype=int32>]

Do you have any idea?
The entire book is available at https://colab.research.google.com/drive/1CofIUYzR7xUsjWfWjDsQ2_scut6xtL8V?usp=sharing

thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions