multi class image classification





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am doing scene classification but , I didn't get the correct image classification ,please help me how to do scene classification
I am create a dictionary like this



  label_dict={'0':'buildings', 

'1':'forest',

'2':'glacier',

'3':'mountain',

'4':'sea' ,

'5':'street' }


But how to classifly the image didn't understandard , I am bulid a model



model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
strides=2,
activation='relu',
input_shape=(32, 32, 3)))
model.add(Dropout(0.5))
model.add(Conv2D(32, kernel_size=(3, 3), strides=2, activation='relu'))
model.add(Dropout(0.5))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(10, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
optimizer='adam',
metrics=['accuracy'])

model.summary(


I got errors are:



ValueError                                Traceback (most recent call last)
<ipython-input-16-4f5a963b4f20> in <module>
1 model.fit(x_train, y_train,
2 batch_size=128,
----> 3 epochs=5 ,validation_data=(x_test, y_test))

~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
950 sample_weight=sample_weight,
951 class_weight=class_weight,
--> 952 batch_size=batch_size)
953 # Prepare validation data.
954 do_validation = False

~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size)
787 feed_output_shapes,
788 check_batch_axis=False, # Don't enforce the batch size.
--> 789 exception_prefix='target')
790
791 # Generate sample-wise weight values given the `sample_weight` and

~/anaconda3/lib/python3.7/site-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
136 ': expected ' + names[i] + ' to have shape ' +
137 str(shape) + ' but got array with shape ' +
--> 138 str(data_shape))
139 return data
140

ValueError: Error when checking target: expected dense_2 to have shape (10,) but got array with shape (6,)


This is my JupyterNotebook like:
http://localhost:8888/notebooks/intel%20image%20classification.ipynb










share|improve this question





























    0















    I am doing scene classification but , I didn't get the correct image classification ,please help me how to do scene classification
    I am create a dictionary like this



      label_dict={'0':'buildings', 

    '1':'forest',

    '2':'glacier',

    '3':'mountain',

    '4':'sea' ,

    '5':'street' }


    But how to classifly the image didn't understandard , I am bulid a model



    model = Sequential()
    model.add(Conv2D(32, kernel_size=(3, 3),
    strides=2,
    activation='relu',
    input_shape=(32, 32, 3)))
    model.add(Dropout(0.5))
    model.add(Conv2D(32, kernel_size=(3, 3), strides=2, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Flatten())
    model.add(Dense(128, activation='relu'))
    model.add(Dense(10, activation='softmax'))

    model.compile(loss=keras.losses.categorical_crossentropy,
    optimizer='adam',
    metrics=['accuracy'])

    model.summary(


    I got errors are:



    ValueError                                Traceback (most recent call last)
    <ipython-input-16-4f5a963b4f20> in <module>
    1 model.fit(x_train, y_train,
    2 batch_size=128,
    ----> 3 epochs=5 ,validation_data=(x_test, y_test))

    ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
    950 sample_weight=sample_weight,
    951 class_weight=class_weight,
    --> 952 batch_size=batch_size)
    953 # Prepare validation data.
    954 do_validation = False

    ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size)
    787 feed_output_shapes,
    788 check_batch_axis=False, # Don't enforce the batch size.
    --> 789 exception_prefix='target')
    790
    791 # Generate sample-wise weight values given the `sample_weight` and

    ~/anaconda3/lib/python3.7/site-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
    136 ': expected ' + names[i] + ' to have shape ' +
    137 str(shape) + ' but got array with shape ' +
    --> 138 str(data_shape))
    139 return data
    140

    ValueError: Error when checking target: expected dense_2 to have shape (10,) but got array with shape (6,)


    This is my JupyterNotebook like:
    http://localhost:8888/notebooks/intel%20image%20classification.ipynb










    share|improve this question

























      0












      0








      0








      I am doing scene classification but , I didn't get the correct image classification ,please help me how to do scene classification
      I am create a dictionary like this



        label_dict={'0':'buildings', 

      '1':'forest',

      '2':'glacier',

      '3':'mountain',

      '4':'sea' ,

      '5':'street' }


      But how to classifly the image didn't understandard , I am bulid a model



      model = Sequential()
      model.add(Conv2D(32, kernel_size=(3, 3),
      strides=2,
      activation='relu',
      input_shape=(32, 32, 3)))
      model.add(Dropout(0.5))
      model.add(Conv2D(32, kernel_size=(3, 3), strides=2, activation='relu'))
      model.add(Dropout(0.5))
      model.add(Flatten())
      model.add(Dense(128, activation='relu'))
      model.add(Dense(10, activation='softmax'))

      model.compile(loss=keras.losses.categorical_crossentropy,
      optimizer='adam',
      metrics=['accuracy'])

      model.summary(


      I got errors are:



      ValueError                                Traceback (most recent call last)
      <ipython-input-16-4f5a963b4f20> in <module>
      1 model.fit(x_train, y_train,
      2 batch_size=128,
      ----> 3 epochs=5 ,validation_data=(x_test, y_test))

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
      950 sample_weight=sample_weight,
      951 class_weight=class_weight,
      --> 952 batch_size=batch_size)
      953 # Prepare validation data.
      954 do_validation = False

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size)
      787 feed_output_shapes,
      788 check_batch_axis=False, # Don't enforce the batch size.
      --> 789 exception_prefix='target')
      790
      791 # Generate sample-wise weight values given the `sample_weight` and

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
      136 ': expected ' + names[i] + ' to have shape ' +
      137 str(shape) + ' but got array with shape ' +
      --> 138 str(data_shape))
      139 return data
      140

      ValueError: Error when checking target: expected dense_2 to have shape (10,) but got array with shape (6,)


      This is my JupyterNotebook like:
      http://localhost:8888/notebooks/intel%20image%20classification.ipynb










      share|improve this question














      I am doing scene classification but , I didn't get the correct image classification ,please help me how to do scene classification
      I am create a dictionary like this



        label_dict={'0':'buildings', 

      '1':'forest',

      '2':'glacier',

      '3':'mountain',

      '4':'sea' ,

      '5':'street' }


      But how to classifly the image didn't understandard , I am bulid a model



      model = Sequential()
      model.add(Conv2D(32, kernel_size=(3, 3),
      strides=2,
      activation='relu',
      input_shape=(32, 32, 3)))
      model.add(Dropout(0.5))
      model.add(Conv2D(32, kernel_size=(3, 3), strides=2, activation='relu'))
      model.add(Dropout(0.5))
      model.add(Flatten())
      model.add(Dense(128, activation='relu'))
      model.add(Dense(10, activation='softmax'))

      model.compile(loss=keras.losses.categorical_crossentropy,
      optimizer='adam',
      metrics=['accuracy'])

      model.summary(


      I got errors are:



      ValueError                                Traceback (most recent call last)
      <ipython-input-16-4f5a963b4f20> in <module>
      1 model.fit(x_train, y_train,
      2 batch_size=128,
      ----> 3 epochs=5 ,validation_data=(x_test, y_test))

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
      950 sample_weight=sample_weight,
      951 class_weight=class_weight,
      --> 952 batch_size=batch_size)
      953 # Prepare validation data.
      954 do_validation = False

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size)
      787 feed_output_shapes,
      788 check_batch_axis=False, # Don't enforce the batch size.
      --> 789 exception_prefix='target')
      790
      791 # Generate sample-wise weight values given the `sample_weight` and

      ~/anaconda3/lib/python3.7/site-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
      136 ': expected ' + names[i] + ' to have shape ' +
      137 str(shape) + ' but got array with shape ' +
      --> 138 str(data_shape))
      139 return data
      140

      ValueError: Error when checking target: expected dense_2 to have shape (10,) but got array with shape (6,)


      This is my JupyterNotebook like:
      http://localhost:8888/notebooks/intel%20image%20classification.ipynb







      opencv image-processing






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 21 at 9:44









      Suresh MithunSuresh Mithun

      62




      62






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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%2faskubuntu.com%2fquestions%2f1120067%2fmulti-class-image-classification%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1120067%2fmulti-class-image-classification%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

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents