Giter VIP home page Giter VIP logo

ValueError: You are passing a target array of shape (32, 1) while using as loss `categorical_crossentropy`. `categorical_crossentropy` expects targets to be binary matrices (1s and 0s) of shape (samples, classes). If your targets are integer classes, you can convert them to the expected format via: ``` from keras.utils import to_categorical y_binary = to_categorical(y_int) ``` about imageai HOT 11 CLOSED

olafenwamoses avatar olafenwamoses commented on May 12, 2024
ValueError: You are passing a target array of shape (32, 1) while using as loss `categorical_crossentropy`. `categorical_crossentropy` expects targets to be binary matrices (1s and 0s) of shape (samples, classes). If your targets are integer classes, you can convert them to the expected format via: ``` from keras.utils import to_categorical y_binary = to_categorical(y_int) ```

from imageai.

Comments (11)

tomaszhajduk avatar tomaszhajduk commented on May 12, 2024 8

Hi,

@allanis79. I'd suggest you to add a second category e.g. no-phone. (you'll have two categories: phone and no-phone)
You need to show to classifier how photo with phone looks like and how photo without phone looks like.
If you'll have just one label then classifier will assign all photos to this label.
EDIT: Probably that's why having one label is not allowed

Hopefully it helps you.

Best regards,
Tomek

from imageai.

krishnaallani avatar krishnaallani commented on May 12, 2024 2

thanks, I solved it. :)

from imageai.

FabianoLothor avatar FabianoLothor commented on May 12, 2024 1

So, I was getting the same issue here and I fixed changing the expected output type.

I was expecting an integer, after parse the integer to a plain-string, the error was gone.

from imageai.

tang6237422 avatar tang6237422 commented on May 12, 2024

can not train one object.

from imageai.

krishnaallani avatar krishnaallani commented on May 12, 2024

I am getting the same error, can I know how you solved it?

from imageai.

OlafenwaMoses avatar OlafenwaMoses commented on May 12, 2024

I am getting the same error, can I know how you solved it?

You must have at least 2 different types of object you need the model to recognize.

from imageai.

krishnaallani avatar krishnaallani commented on May 12, 2024

thanks for your quick reply.
0

see the above image? I want to detect the phone in that image. So I have only one label. Any ideas on how to approach the above problem?

from imageai.

ilirosmanaj avatar ilirosmanaj commented on May 12, 2024

@allanis79 , I guess you created the no-phone class, right? If that is the case, how many images did you need for this class - and, if applicable - did you do any comparison on the effect of the number of images for this class?

from imageai.

krishnaallani avatar krishnaallani commented on May 12, 2024

yes I did create a no phone class. I made around 700 images. I didn't compare it with anything else.

from imageai.

TheARKitectsEND avatar TheARKitectsEND commented on May 12, 2024

I know that this is old and may not be watched, but quick question. If I am doing something similar, basically it is or isn't there, do I need provide consistent images for the 'not there' option or can I provide random images? For the testing does it need to be anything consistent for the 'not there' option?

from imageai.

ilirosmanaj avatar ilirosmanaj commented on May 12, 2024

I think the more images you provide for the not-there class, the better it is. In your case I think it totally makes sense for them to be random and include as much different domains as possible

from imageai.

Related Issues (20)

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.