ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,)Scikit learn (Python 3.5): Do I need to import a library to make this work?ValueError: Error when checking input: expected time_distributed_46_input to have 5 dimensions, but got array with shape (200, 200, 3)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (393613, 50)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (10, 1)Tensorflow keras with tf dataset inputValueError: Error when checking target: expected output to have shape (1,) but got array with shape (2,)LSTM Nerual Network Input/Output dimensions errorKeras batch_size problem when using model.fit in custom layersNeural Network classificationValueError: Error when checking input: expected conv1d_81_input to have shape (177, 100) but got array with shape (1, 177)

Mapping arrows in commutative diagrams

Why is my log file so massive? 22gb. I am running log backups

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

What to wear for invited talk in Canada

What happens when a metallic dragon and a chromatic dragon mate?

Does the average primeness of natural numbers tend to zero?

Is it possible to make sharp wind that can cut stuff from afar?

Einstein metrics on spheres

Crop image to path created in TikZ?

Finding files for which a command fails

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Check if two datetimes are between two others

Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?

Email Account under attack (really) - anything I can do?

How to move the player while also allowing forces to affect it

"My colleague's body is amazing"

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

Need help identifying/translating a plaque in Tangier, Morocco

Is Fable (1996) connected in any way to the Fable franchise from Lionhead Studios?

Can I find out the caloric content of bread by dehydrating it?

How can I fix this gap between bookcases I made?

Patience, young "Padovan"

"listening to me about as much as you're listening to this pole here"

Can I legally use front facing blue light in the UK?



ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,)


Scikit learn (Python 3.5): Do I need to import a library to make this work?ValueError: Error when checking input: expected time_distributed_46_input to have 5 dimensions, but got array with shape (200, 200, 3)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (393613, 50)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (10, 1)Tensorflow keras with tf dataset inputValueError: Error when checking target: expected output to have shape (1,) but got array with shape (2,)LSTM Nerual Network Input/Output dimensions errorKeras batch_size problem when using model.fit in custom layersNeural Network classificationValueError: Error when checking input: expected conv1d_81_input to have shape (177, 100) but got array with shape (1, 177)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:
ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:






import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd

!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls

batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50

train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']

x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']

Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)

model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])

model.fit(Train, epochs=epochs, steps_per_epoch=600)





I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?



Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.










share|improve this question






























    0















    I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:
    ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:






    import tensorflow as tf
    from tensorflow.keras import layers
    import numpy as np
    import pandas as pd

    !git clone https://github.com/DanorRon/my_repo
    %cd my_repo
    !ls

    batch_size = 100
    epochs = 10
    alpha = 0.01
    lambda_ = 0.01
    h1 = 50

    train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
    test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

    x_train = train.loc[:, '1x1':'28x28']
    y_train = train.loc[:, 'label']

    x_test = test.loc[:, '1x1':'28x28']
    y_test = test.loc[:, 'label']

    Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
    Train.batch(batch_size).repeat(10).shuffle(1000)

    model = tf.keras.Sequential()
    model.add(layers.Dense(784, input_shape=(784,)))
    model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
    model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

    model.compile(optimizer=tf.train.AdamOptimizer(alpha),
    loss = 'categorical_crossentropy',
    metrics = ['accuracy'])

    model.fit(Train, epochs=epochs, steps_per_epoch=600)





    I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?



    Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.










    share|improve this question


























      0












      0








      0








      I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:
      ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:






      import tensorflow as tf
      from tensorflow.keras import layers
      import numpy as np
      import pandas as pd

      !git clone https://github.com/DanorRon/my_repo
      %cd my_repo
      !ls

      batch_size = 100
      epochs = 10
      alpha = 0.01
      lambda_ = 0.01
      h1 = 50

      train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
      test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

      x_train = train.loc[:, '1x1':'28x28']
      y_train = train.loc[:, 'label']

      x_test = test.loc[:, '1x1':'28x28']
      y_test = test.loc[:, 'label']

      Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
      Train.batch(batch_size).repeat(10).shuffle(1000)

      model = tf.keras.Sequential()
      model.add(layers.Dense(784, input_shape=(784,)))
      model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
      model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

      model.compile(optimizer=tf.train.AdamOptimizer(alpha),
      loss = 'categorical_crossentropy',
      metrics = ['accuracy'])

      model.fit(Train, epochs=epochs, steps_per_epoch=600)





      I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?



      Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.










      share|improve this question
















      I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:
      ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:






      import tensorflow as tf
      from tensorflow.keras import layers
      import numpy as np
      import pandas as pd

      !git clone https://github.com/DanorRon/my_repo
      %cd my_repo
      !ls

      batch_size = 100
      epochs = 10
      alpha = 0.01
      lambda_ = 0.01
      h1 = 50

      train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
      test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

      x_train = train.loc[:, '1x1':'28x28']
      y_train = train.loc[:, 'label']

      x_test = test.loc[:, '1x1':'28x28']
      y_test = test.loc[:, 'label']

      Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
      Train.batch(batch_size).repeat(10).shuffle(1000)

      model = tf.keras.Sequential()
      model.add(layers.Dense(784, input_shape=(784,)))
      model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
      model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

      model.compile(optimizer=tf.train.AdamOptimizer(alpha),
      loss = 'categorical_crossentropy',
      metrics = ['accuracy'])

      model.fit(Train, epochs=epochs, steps_per_epoch=600)





      I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?



      Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.






      import tensorflow as tf
      from tensorflow.keras import layers
      import numpy as np
      import pandas as pd

      !git clone https://github.com/DanorRon/my_repo
      %cd my_repo
      !ls

      batch_size = 100
      epochs = 10
      alpha = 0.01
      lambda_ = 0.01
      h1 = 50

      train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
      test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

      x_train = train.loc[:, '1x1':'28x28']
      y_train = train.loc[:, 'label']

      x_test = test.loc[:, '1x1':'28x28']
      y_test = test.loc[:, 'label']

      Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
      Train.batch(batch_size).repeat(10).shuffle(1000)

      model = tf.keras.Sequential()
      model.add(layers.Dense(784, input_shape=(784,)))
      model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
      model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

      model.compile(optimizer=tf.train.AdamOptimizer(alpha),
      loss = 'categorical_crossentropy',
      metrics = ['accuracy'])

      model.fit(Train, epochs=epochs, steps_per_epoch=600)





      import tensorflow as tf
      from tensorflow.keras import layers
      import numpy as np
      import pandas as pd

      !git clone https://github.com/DanorRon/my_repo
      %cd my_repo
      !ls

      batch_size = 100
      epochs = 10
      alpha = 0.01
      lambda_ = 0.01
      h1 = 50

      train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
      test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')

      x_train = train.loc[:, '1x1':'28x28']
      y_train = train.loc[:, 'label']

      x_test = test.loc[:, '1x1':'28x28']
      y_test = test.loc[:, 'label']

      Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
      Train.batch(batch_size).repeat(10).shuffle(1000)

      model = tf.keras.Sequential()
      model.add(layers.Dense(784, input_shape=(784,)))
      model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
      model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))

      model.compile(optimizer=tf.train.AdamOptimizer(alpha),
      loss = 'categorical_crossentropy',
      metrics = ['accuracy'])

      model.fit(Train, epochs=epochs, steps_per_epoch=600)






      python tensorflow machine-learning google-colaboratory tf.keras






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 15:16







      Ronan Venkat

















      asked Mar 22 at 1:37









      Ronan VenkatRonan Venkat

      4415




      4415






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).






          share|improve this answer























          • Is there a way to fix the problem without splitting the dataset?

            – Ronan Venkat
            Mar 22 at 13:13











          • Also, how do I break the dataset apart? I can’t find anything on the docs.

            – Ronan Venkat
            Mar 22 at 16:40












          • from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

            – david
            Mar 25 at 2:24












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291653%2fvalueerror-error-when-checking-input-expected-dense-18-input-to-have-shape-78%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).






          share|improve this answer























          • Is there a way to fix the problem without splitting the dataset?

            – Ronan Venkat
            Mar 22 at 13:13











          • Also, how do I break the dataset apart? I can’t find anything on the docs.

            – Ronan Venkat
            Mar 22 at 16:40












          • from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

            – david
            Mar 25 at 2:24
















          0














          I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).






          share|improve this answer























          • Is there a way to fix the problem without splitting the dataset?

            – Ronan Venkat
            Mar 22 at 13:13











          • Also, how do I break the dataset apart? I can’t find anything on the docs.

            – Ronan Venkat
            Mar 22 at 16:40












          • from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

            – david
            Mar 25 at 2:24














          0












          0








          0







          I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).






          share|improve this answer













          I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 2:22









          daviddavid

          597




          597












          • Is there a way to fix the problem without splitting the dataset?

            – Ronan Venkat
            Mar 22 at 13:13











          • Also, how do I break the dataset apart? I can’t find anything on the docs.

            – Ronan Venkat
            Mar 22 at 16:40












          • from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

            – david
            Mar 25 at 2:24


















          • Is there a way to fix the problem without splitting the dataset?

            – Ronan Venkat
            Mar 22 at 13:13











          • Also, how do I break the dataset apart? I can’t find anything on the docs.

            – Ronan Venkat
            Mar 22 at 16:40












          • from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

            – david
            Mar 25 at 2:24

















          Is there a way to fix the problem without splitting the dataset?

          – Ronan Venkat
          Mar 22 at 13:13





          Is there a way to fix the problem without splitting the dataset?

          – Ronan Venkat
          Mar 22 at 13:13













          Also, how do I break the dataset apart? I can’t find anything on the docs.

          – Ronan Venkat
          Mar 22 at 16:40






          Also, how do I break the dataset apart? I can’t find anything on the docs.

          – Ronan Venkat
          Mar 22 at 16:40














          from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

          – david
          Mar 25 at 2:24






          from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.

          – david
          Mar 25 at 2:24




















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291653%2fvalueerror-error-when-checking-input-expected-dense-18-input-to-have-shape-78%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해