Git Product home page Git Product logo

Comments (4)

RaphaelMeudec avatar RaphaelMeudec commented on May 21, 2024 2

Terribly sorry for not answering earlier. My guess is that the condition np.all(np.argmax(label) == 0) is not met when you use the flow_from_directory, so your validation class zero is empty and hence has shape [0]. To validate this, could you tell what y looks like?

I'm looking for the next release to support ImageDataGenerator and tf.data.Dataset, which should solve this.

from tf-explain.

VictorW96 avatar VictorW96 commented on May 21, 2024 2

I have the same problem. Is there support for the ImageDataGenerator in version 2.1.0? I haven't found it yet.

from tf-explain.

twsl avatar twsl commented on May 21, 2024

A possible solution could look like this:

valid_batches = valid_datagen.flow_from_directory(...)
(x,y) = valid_batches.next()
validation_class_zero = (np.array([
    el for el, label in zip(x,y)
    if np.all(np.argmax(label) == 0)
][0:5]), None)

But when i try to select the first conv layer in InceptionResNetV2, I get the following error:
ValueError: Input 0 of layer conv2d is incompatible with the layer: expected ndim=4, found ndim=1. Full shape received: [0]
And I'm not sure, if this is related to my workaround or something else.

from tf-explain.

twsl avatar twsl commented on May 21, 2024

Terribly sorry for not answering earlier 😄
Looks like your thought was on point, the condition np.all is aparently not always met.

(x,y) = valid_batches.next()
for el, label in zip(x,y):
    print(el.shape)
    print(label.shape)
    print(np.argmax(label))

validation_class_zero = (np.array([
    el for el, label in zip(x,y)
    if np.all(np.argmax(label) == 0)
][0:5]), None)
print(validation_class_zero)

(300, 300, 3)
(3,)
0
(300, 300, 3)
(3,)
0
(300, 300, 3)
(3,)
1
(300, 300, 3)
(3,)
1
(300, 300, 3)
(3,)
1
(300, 300, 3)
(3,)
1
(array([], dtype=float64), None)

This is probably due to the fact, that I rely on transfer learning and do not have a sufficient amount of samples.

from tf-explain.

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.