Coder Social home page Coder Social logo

ValueError: Input 0 of layer "sequential_2" is incompatible with the layer: expected shape=(None, 28, 28, 1), found shape=(1, 14, 14, 1) about tensorflow-with-khom HOT 7 CLOSED

khomz avatar khomz commented on June 17, 2024
ValueError: Input 0 of layer "sequential_2" is incompatible with the layer: expected shape=(None, 28, 28, 1), found shape=(1, 14, 14, 1)

from tensorflow-with-khom.

Comments (7)

KhomZ avatar KhomZ commented on June 17, 2024

https://stackoverflow.com/questions/71038082/valueerror-input-0-of-layer-sequential-is-incompatible-with-the-layer-expect

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

Your input has to match the expected format of the input layer of your model. You can use reshape to get the right format, expected the dimension match, otherwise you'll need to pad the missing dimensions.

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

https://stackoverflow.com/questions/65225918/valueerror-input-0-of-layer-sequential-is-incompatible-with-the-layer-expecte

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

Might be

Problem with this line model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 1))) Input dataset has RGB images input_shape should be (32,32,3) where 3 stands for 3 RGB channels and whereas '1' is used for grayscale image

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

https://stackoverflow.com/questions/66328999/valueerror-input-0-of-layer-sequential-is-incompatible-with-the-layer-expected

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

finally corrected code:

`def make_discriminator_model():
model = tf.keras.Sequential()
model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',
input_shape=[14, 14, 1]))
# model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',
# input_shape=[28, 28, 1]))

model.add(layers.LeakyReLU())
model.add(layers.Dropout(0.3))

model.add(layers.Conv2D(128, (5, 5), strides=(2, 2), padding='same'))
model.add(layers.LeakyReLU())
model.add(layers.Dropout(0.3))

model.add(layers.Flatten())
model.add(layers.Dense(1))

return model`

from tensorflow-with-khom.

KhomZ avatar KhomZ commented on June 17, 2024

model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',input_shape=[28, 28, 1]))

change this to :

model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',input_shape=[14, 14, 1]))

from tensorflow-with-khom.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.