{
  "id": 277336,
  "title": "Help me about a Keras error",
  "url": "/competitions/digit-recognizer/discussion/277336",
  "author_name": "Makoto Ono",
  "post_date": "2021-10-09T00:42:26.604000",
  "votes": 1,
  "comment_count": 4,
  "views": null,
  "content": "<p>I tried to run my following code for Digit-Recognizer, however, 'ValueError: Shapes (10, 10) and (10, 784) are incompatible' were outputed. Are there anyone who points out my problem? Help me. Thank you for your kindness.</p>\n<p>import pandas as pd<br>\nimport numpy as np<br>\nfrom tensorflow.keras.models import Sequential<br>\nfrom tensorflow.keras.layers import Dense<br>\nfrom tensorflow.keras.optimizers import Adam<br>\nfrom tensorflow.keras.utils import to_categorical</p>\n<p>d_train = pd.read_csv('train.csv')<br>\nx_train = d_train.drop(columns='label')<br>\ny_train = to_categorical(d_train.loc[:, 'label'], 10)</p>\n<p>x_test = pd.read_csv('test.csv')</p>\n<p>model = Sequential()<br>\nmodel.add = Dense(units=64, activation='relu', input_shape=(784,))<br>\nmodel.add = Dense(units=32, activation='relu')<br>\nmodel.add = Dense(units=10, activation='softmax')<br>\nmodel.compile(loss='categorical_crossentropy', optimizer=Adam(), metrics=['accuracy'])<br>\nmodel.fit(x_train, y_train, epochs=20, batch_size=10, validation_split=0.2)<br>\ny = model.predict(x_test, batch_size=5)</p>",
  "messages": [
    {
      "id": 1538971,
      "postDate": "2021-10-09T00:42:26.603Z",
      "content": "<p>I tried to run my following code for Digit-Recognizer, however, 'ValueError: Shapes (10, 10) and (10, 784) are incompatible' were outputed. Are there anyone who points out my problem? Help me. Thank you for your kindness.</p>\n<p>import pandas as pd<br>\nimport numpy as np<br>\nfrom tensorflow.keras.models import Sequential<br>\nfrom tensorflow.keras.layers import Dense<br>\nfrom tensorflow.keras.optimizers import Adam<br>\nfrom tensorflow.keras.utils import to_categorical</p>\n<p>d_train = pd.read_csv('train.csv')<br>\nx_train = d_train.drop(columns='label')<br>\ny_train = to_categorical(d_train.loc[:, 'label'], 10)</p>\n<p>x_test = pd.read_csv('test.csv')</p>\n<p>model = Sequential()<br>\nmodel.add = Dense(units=64, activation='relu', input_shape=(784,))<br>\nmodel.add = Dense(units=32, activation='relu')<br>\nmodel.add = Dense(units=10, activation='softmax')<br>\nmodel.compile(loss='categorical_crossentropy', optimizer=Adam(), metrics=['accuracy'])<br>\nmodel.fit(x_train, y_train, epochs=20, batch_size=10, validation_split=0.2)<br>\ny = model.predict(x_test, batch_size=5)</p>",
      "rawMarkdown": "I tried to run my following code for Digit-Recognizer, however, 'ValueError: Shapes (10, 10) and (10, 784) are incompatible' were outputed. Are there anyone who points out my problem? Help me. Thank you for your kindness.\n\nimport pandas as pd\nimport numpy as np\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.utils import to_categorical\n\nd_train = pd.read_csv('train.csv')\nx_train = d_train.drop(columns='label')\ny_train = to_categorical(d_train.loc[:, 'label'], 10)\n\nx_test = pd.read_csv('test.csv')\n\nmodel = Sequential()\nmodel.add = Dense(units=64, activation='relu', input_shape=(784,))\nmodel.add = Dense(units=32, activation='relu')\nmodel.add = Dense(units=10, activation='softmax')\nmodel.compile(loss='categorical_crossentropy', optimizer=Adam(), metrics=['accuracy'])\nmodel.fit(x_train, y_train, epochs=20, batch_size=10, validation_split=0.2)\ny = model.predict(x_test, batch_size=5)",
      "votes": 1
    },
    {
      "id": 1643069,
      "postDate": "2022-01-09T03:03:20.010Z",
      "content": "<p>Did you fix this error?</p>",
      "rawMarkdown": "Did you fix this error?",
      "replies": [
        {
          "id": 1643088,
          "postDate": "2022-01-09T03:59:28.793Z",
          "content": "<p>I have already fixed this issue. Thank you for your kindness.</p>",
          "rawMarkdown": "I have already fixed this issue. Thank you for your kindness."
        }
      ]
    },
    {
      "id": 1539300,
      "postDate": "2021-10-09T09:45:51.407Z",
      "content": "<p>I found my fault. I made a mistake for model.add description.</p>",
      "rawMarkdown": "I found my fault. I made a mistake for model.add description.",
      "replies": [
        {
          "id": 1676937,
          "postDate": "2022-02-05T12:09:58.537Z",
          "content": "<p>the range is 0~783?</p>",
          "rawMarkdown": "the range is 0~783?"
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1643069,
      "author_name": "Gansukh03",
      "author_url": "",
      "post_date": "2022-01-09T03:03:20.010000",
      "content": "<p>Did you fix this error?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1643088,
          "author_name": "Makoto Ono",
          "author_url": "",
          "post_date": "2022-01-09T03:59:28.793000",
          "content": "<p>I have already fixed this issue. Thank you for your kindness.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1539300,
      "author_name": "Makoto Ono",
      "author_url": "",
      "post_date": "2021-10-09T09:45:51.407000",
      "content": "<p>I found my fault. I made a mistake for model.add description.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1676937,
          "author_name": "Rungen",
          "author_url": "",
          "post_date": "2022-02-05T12:09:58.537000",
          "content": "<p>the range is 0~783?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1538971": "I tried to run my following code for Digit-Recognizer, however, 'ValueError: Shapes (10, 10) and (10, 784) are incompatible' were outputed. Are there anyone who points out my problem? Help me. Thank you for your kindness.\n\nimport pandas as pd\nimport numpy as np\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.utils import to_categorical\n\nd_train = pd.read_csv('train.csv')\nx_train = d_train.drop(columns='label')\ny_train = to_categorical(d_train.loc[:, 'label'], 10)\n\nx_test = pd.read_csv('test.csv')\n\nmodel = Sequential()\nmodel.add = Dense(units=64, activation='relu', input_shape=(784,))\nmodel.add = Dense(units=32, activation='relu')\nmodel.add = Dense(units=10, activation='softmax')\nmodel.compile(loss='categorical_crossentropy', optimizer=Adam(), metrics=['accuracy'])\nmodel.fit(x_train, y_train, epochs=20, batch_size=10, validation_split=0.2)\ny = model.predict(x_test, batch_size=5)",
    "1643069": "Did you fix this error?",
    "1539300": "I found my fault. I made a mistake for model.add description."
  }
}