when I define Siamese model, my model.summary for both Siamese and sequential agree (it prints outputs). But when I run w3_unittest.test_Siamese(Siamese), I get those errors:
Layer ‘sequential’ has an incorrect input shape.
Expected:(None,),
Got:(None, 1).
Layer ‘sequential’ has an incorrect input shape.
Expected:(None,),
Got:(None, 1).
23 tests passed
2 tests failed
Moreover, this is a pic from a post by previous student:
And this is my pic:
in sequential on top I have [(None, 1)] and previous student has [(None,)].
Any suggestion, may be someone who had this issue before? Thank you!
Hi @Dennis_Sinitsky
The images show that you have different text_vectorization_input
, text_vectorization
etc. (don’t forget to set name=
for each layer).
Make sure you understand what Input is, especially the first parameter.
Since we use a text_vectorizer
as the first layer in our sequential, the input shape should be (1). In other words, the input is the entire sentence.
Also, don’t forget to set the correct dtype=
argument.
Cheers
Hi arvyzukai,
Thank you for your reply. I added name to text vectorization layer called ‘text_vectorization’ and now it shows in the model plot. But I cannot resolve the error from w3_unittest.test_Siamese(Siamese) test.
My input shape is defined as (1,) and I think it is correct because we input one string at a time. I also tried (None,) and (1). For (1) I got the same error as in (1,):
Layer ‘sequential’ has an incorrect input shape.
Expected:(None,),
Got:(None, 1).
Layer ‘sequential’ has an incorrect input shape.
Expected:(None,),
Got:(None, 1).
23 tests passed
2 tests failed
For (None,) I get error which clearly shows that this is not the right shape and it should not be based on my understanding.
My dtype is defined in layers.Input as tf.string (without quotation marks) which I think is correct.
For future readers, the OP mistake was creating new text vectorization layer inside this function, while what you need is already provided for you:
Args:
text_vectorizer (TextVectorization): TextVectorization instance, already adapted to your training data.
So what you need is to just add this instance to your branch
sequential model.
Cheers
2 Likes