Get problem at Assignment C3W3: ValueError: A `Concatenate` layer should be called on a list of at least 1 input. Received: input_shape=(None, None)

ValueError: A Concatenate layer should be called on a list of at least 1 input. Received: input_shape=(None, None)

Image removed as posting grade cell codes are against community guidelines

Check data type and size of inputs as well as branches? Try then to find if the problem is with your input shapes of the braches shapes and maybe something is wrong the branch(code) you wrote jsut above the inputs!

this is lab (not assignemnt)


I did nothing different.

I just make Input with Shape(1,)

Because in the assignment that the "expected output " indicates it.

any one can help?

ValueError                                Traceback (most recent call last)
Cell In[88], line 2
      1 # check your model
----> 2 model = Siamese(text_vectorization, vocab_size=text_vectorization.vocabulary_size())
      3 model.build(input_shape=None)
      4 model.summary()

Cell In[87], line 40, in Siamese(text_vectorizer, vocab_size, d_feature)
     37 branch2 = branch(input2[0])
     38 # Define the Concatenate layer. You should concatenate columns, you can fix this using the `axis`parameter. 
     39 # This layer is applied over the outputs of each branch of the Siamese network
---> 40 conc = tf.keras.layers.Concatenate(axis=1, name='conc_1_2')([branch1, 
     41                                                              branch2,])
     43 ### END CODE HERE ###
     45 return tf.keras.models.Model(inputs=[input1, input2], outputs=conc, name="SiameseModel")

File /usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
     67     filtered_tb = _process_traceback_frames(e.__traceback__)
     68     # To get the full stack trace, call:
     69     # `tf.debugging.disable_traceback_filtering()`
---> 70     raise e.with_traceback(filtered_tb) from None
     71 finally:
     72     del filtered_tb

File /usr/local/lib/python3.8/dist-packages/keras/src/layers/merging/concatenate.py:98, in Concatenate.build(self, input_shape)
     94 @tf_utils.shape_type_conversion
     95 def build(self, input_shape):
     96     # Used purely for shape validation.
     97     if len(input_shape) < 1 or not isinstance(input_shape[0], tuple):
---> 98         raise ValueError(
     99             "A `Concatenate` layer should be called on a list of "
    100             f"at least 1 input. Received: input_shape={input_shape}"
    101         )
    102     if all(shape is None for shape in input_shape):
    103         return

ValueError: A `Concatenate` layer should be called on a list of at least 1 input. Received: input_shape=(None, None)

Are you running this in your own environment?
It could be you’ve run into a tool and package version incompatibility issue.

1 Like

Thank you for the reply. @TMosh @gent.spah
I think that I have solved the problem.
The problem was at lambda.
I defined a function instead of inline lambda, however I forgot to use “return” keyword.

The Tensorflow always fires an issue that does not link to the root cause.

:smile:

3 Likes

On the lighter side, to tensorflow/keras’s credit the error log gave some hints -