Skip to content

ValueError: Exception encountered when calling layer "sequential" (type Sequential) #256

Answered by mrdbourke
Citizen-Dan asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Citizen-Dan,

This looks like it's an update from TensorFlow 2.7.0 that will break some code.

See the TensorFlow 2.7.0 update here: https://github.com/tensorflow/tensorflow/releases/tag/v2.7.0

But the main thing is incorrect input shapes for models, in essence fit() no longer turns data from (batch_size, ) to (batch_size, 1).

So we have to do it manually by adding an extra dimension.

Error

The error you might see if passing a scalar to any TensorFlow training function:

ValueError: Exception encountered when calling layer "sequential" (type Sequential).
    
    Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1. Full shape received: (None,)
    …

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
8 replies
@mrdbourke
Comment options

@happymondaynkanta
Comment options

@Skorkmaz88
Comment options

@DebjitHore
Comment options

@C3ald
Comment options

Answer selected by Citizen-Dan
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Dikshith4128
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants