Code Monkey home page Code Monkey logo

Comments (26)

swghosh avatar swghosh commented on July 19, 2024 23

The specific function (tf.keras.preprocessing.image_dataset_from_directory) is not available under TensorFlow v2.1.x or v2.2.0 yet. It is only available with the tf-nightly builds and is existent in the source code of the master branch.
https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image_dataset_from_directory

For more information about installing nightly builds of TensorFlow, you can refer to https://www.tensorflow.org/install or use

pip install tf-nightly

Thanks.

from keras-io.

chasecockrell avatar chasecockrell commented on July 19, 2024 12

Its pretty sad that this team can't even provide a working tutorial

from keras-io.

fchollet avatar fchollet commented on July 19, 2024 10

@fchollet Is the whole documentation hosted at keras.io website designed around tf-nightly as of now?

Yes. These features will be in TF 2.3. Past 2.3 we don't expect that there will be discrepancies between the docs and the latest released API.

from keras-io.

surak avatar surak commented on July 19, 2024 6

Yes. These features will be in TF 2.3. Past 2.3 we don't expect that there will be discrepancies between the docs and the latest released API.
The same error is still there in Tensorflow Version 2.4

Can confirm.
The example in https://www.tensorflow.org/tutorials/load_data/images uses keras.utils,
and both are missing:

>>> tf.__version__
'2.4.1'
>>> import tensorflow.keras.utils
>>> dir(tf.keras.utils)
['CustomObjectScope', 'GeneratorEnqueuer', 'OrderedEnqueuer', 'Progbar', 'Sequence', 'SequenceEnqueuer', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_sys', 'custom_object_scope', 'deserialize_keras_object', 'get_custom_objects', 'get_file', 'get_registered_name', 'get_registered_object', 'get_source_inputs', 'model_to_dot', 'normalize', 'pack_x_y_sample_weight', 'plot_model', 'register_keras_serializable', 'serialize_keras_object', 'to_categorical', 'unpack_x_y_sample_weight']

>>> import tensorflow.keras.preprocessing
2021-10-17 16:13:03.445692: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
>>> dir(tensorflow.keras.preprocessing)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_sys', 'image', 'image_dataset_from_directory', 'sequence', 'text', 'text_dataset_from_directory', 'timeseries_dataset_from_array']

from keras-io.

pathikg avatar pathikg commented on July 19, 2024 5

@fchollet Is the whole documentation hosted at keras.io website designed around tf-nightly as of now?

Yes. These features will be in TF 2.3. Past 2.3 we don't expect that there will be discrepancies between the docs and the latest released API.

The same error is still there in Tensorflow Version 2.4

from keras-io.

esraa-abdelmaksoud avatar esraa-abdelmaksoud commented on July 19, 2024 4

I've got the same problem using the version '2.4.0', but the problem was solved with the following:
tf.keras.preprocessing.image_dataset_from_directory()

from keras-io.

natelee-tw avatar natelee-tw commented on July 19, 2024 3

The same issue too in TF2.5.2

tf.__version__
'2.5.2'
dir(tf.keras.utils)
['CustomObjectScope', 'GeneratorEnqueuer', 'OrderedEnqueuer', 'Progbar', 'Sequence', 'SequenceEnqueuer', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_sys', 'custom_object_scope', 'deserialize_keras_object', 'experimental', 'get_custom_objects', 'get_file', 'get_registered_name', 'get_registered_object', 'get_source_inputs', 'model_to_dot', 'normalize', 'pack_x_y_sample_weight', 'plot_model', 'register_keras_serializable', 'serialize_keras_object', 'to_categorical', 'unpack_x_y_sample_weight']

from keras-io.

swghosh avatar swghosh commented on July 19, 2024 1

I wish I can transition my GPU too ;) So what's the point of Keras and why not just use TF directly ? I think I'm missing some point :(

Seems like you're deep learning on an AMD GPU with Plaid ML + Keras!
And, you're correct TensorFlow 2.0 is tightly coupled with Keras API and hence, using tf.keras from tensorflow_v2 is the current default for Keras!

https://github.com/keras-team/keras#multi-backend-keras-and-tfkeras

from keras-io.

TByte007 avatar TByte007 commented on July 19, 2024 1

I wish I can transition my GPU too ;) So what's the point of Keras and why not just use TF directly ? I think I'm missing some point :(

Seems like you're deep learning on an AMD GPU with Plaid ML + Keras!
And, you're correct TensorFlow 2.0 is tightly coupled with Keras API and hence, using tf.keras from tensorflow_v2 is the current default for Keras!

https://github.com/keras-team/keras

Yes I currently only have AMD GPUs and I wrote GA OpenCL kernel for it it was working fine but I wanted to see what other people are doing and I was sure there are LOT better implementation than mine for machine learning (and better optimized kernels). But everything I find is NVIDIA bound - it;s like NVIDIA is paying developers NOT to use anything else and it's really frustrating and it's making me not to want to even see NVIDIA product in my life ;) I can always go buy a new GPU but Now i'm pissed at NVIDIA lol.

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

After reviewing some parts of the new keras.io website, I could also find other examples and source code that involves function calls and reference to classes only available with tf-nightly (or in the master branch of TensorFlow). As also observed in, https://keras.io/examples/keras_recipes/quasi_svm/ where the tf.keras.layers.experimental.RandomFourierFeatures have been used.

from tensorflow.keras.layers.experimental import RandomFourierFeatures

model = keras.Sequential(
[
keras.Input(shape=(784,)),
RandomFourierFeatures(
output_dim=4096, scale=10.0, kernel_initializer="gaussian"
),
layers.Dense(units=10),
]
)

/cc: @fchollet Is the whole documentation hosted at keras.io website designed around tf-nightly as of now?

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

Thanks for the clarification.

from keras-io.

bsdis avatar bsdis commented on July 19, 2024

When is TF 2.3 expected to be released more or less?

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

TensorFlow 2.2 was just released one and half weeks before. Although, there is no definitive announcement about the exact release date of next release cycle, the TensorFlow community usually releases major version updates like once in 5-6 months.
Meanwhile, most of the code on this repo can be runt using the tf-nightly package as well as most examples should be fine when directly runt on TensorFlow 2.2 itself.

If you are experiencing any issues, please try:

pip install tf-nightly # nightly builds of the tensorflow master branch released each night

And, you should be up and doing in no time!

from keras-io.

pranabdas457 avatar pranabdas457 commented on July 19, 2024

I am also getting the same error. Can anyone help me how to resolve this?

module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

Hi @pranabdas457

TensorFlow 2.2 was just released one and half weeks before. Although, there is no definitive announcement about the exact release date of next release cycle, the TensorFlow community usually releases major version updates like once in 5-6 months.
Meanwhile, most of the code on this repo can be runt using the tf-nightly package as well as most examples should be fine when directly runt on TensorFlow 2.2 itself.

If you are experiencing any issues, please try:

pip install tf-nightly # nightly builds of the tensorflow master branch released each night

And, you should be up and doing in no time!

Please try installing the tf-nightly package in case you're trying to use image_dataset_from_directory function in your code.

from keras-io.

lilly-chen avatar lilly-chen commented on July 19, 2024

Hi i was gettin "module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'" so i run the pip install tf-nightly.

but now i am getting a new error message cannot import name 'image_dataset_from_directory' from 'tensorflow.keras.preprocessing.image' (/Users/xxx/anaconda3/lib/python3.7/site-packages/tensorflow/keras/preprocessing/image/init.py)

appreciate any suggestion to fix this! Thanks

from keras-io.

christian-unoxx avatar christian-unoxx commented on July 19, 2024

Hi i was gettin "module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'" so i run the pip install tf-nightly.

but now i am getting a new error message cannot import name 'image_dataset_from_directory' from 'tensorflow.keras.preprocessing.image' (/Users/xxx/anaconda3/lib/python3.7/site-packages/tensorflow/keras/preprocessing/image/init.py)

appreciate any suggestion to fix this! Thanks

I also experienced this the other day. (I haven't tried it again since then, though).

from keras-io.

shilan avatar shilan commented on July 19, 2024

Now that tensorflow 2.3 is released, image_dataset_from_directory actually works.

from keras-io.

TByte007 avatar TByte007 commented on July 19, 2024

Does that mean that if I use PlaidML there is no chance I can use those functions ?

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

Does that mean that if I use PlaidML there is no chance I can use those functions ?

Keras has deprecated support for multi backends for quite some time now. The only option here to try out the every new feature that Keras API offers is to stick to the TensorFlow backend a.k.a. tf.keras.

Look into transitioning your codebase to tf.keras and TensorFlow 2.0 for all the goodness that comes with Eager execution and high level Deep Learning APIs.

from keras-io.

TByte007 avatar TByte007 commented on July 19, 2024

I wish I can transition my GPU too ;) So what's the point of Keras and why not just use TF directly ? I think I'm missing some point :(

from keras-io.

swghosh avatar swghosh commented on July 19, 2024

@TByte007 Probably, you should try ROCm TensorFlow which is a community supported TF port delivering implementations so that we can run TF2.x on AMD GPUs.

https://github.com/ROCmSoftwarePlatform/tensorflow-upstream

from keras-io.

TByte007 avatar TByte007 commented on July 19, 2024

@TByte007 Probably, you should try ROCm TensorFlow which is a community supported TF port delivering implementations so that we can run TF2.x on AMD GPUs.

https://github.com/ROCmSoftwarePlatform/tensorflow-upstream

That's what I'm about to try given the chance, the problem is that ROCm is not supported under Windows and I cant fit my AMD cards (or even one card) in the Linux machine I have (well , it's never easy I guess). So far PlaidML-Keras under windows works fine and faster than my implementation but sooner or later I have to switch.

from keras-io.

MustafaAlperenYILDIRIM avatar MustafaAlperenYILDIRIM commented on July 19, 2024

The specific function (tf.keras.preprocessing.image_dataset_from_directory) is not available under TensorFlow v2.1.x or v2.2.0 yet. It is only available with the tf-nightly builds and is existent in the source code of the master branch.
https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image_dataset_from_directory

For more information about installing nightly builds of TensorFlow, you can refer to https://www.tensorflow.org/install or use

pip install tf-nightly

Thanks.

tf-nightly library fixed the error. Thanks

from keras-io.

JMIdeaMaker avatar JMIdeaMaker commented on July 19, 2024

It's March and the problems are still here...

from keras-io.

pandysong avatar pandysong commented on July 19, 2024

Same issue here on mac

>>> tf.__version__
'2.3.0'

>>> dir(tf.keras.utils)
['CustomObjectScope', 'GeneratorEnqueuer', 'HDF5Matrix', 'OrderedEnqueuer', 'Progbar', 'Sequence', 'SequenceEnqueuer', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_sys', 'convert_all_kernels_in_model', 'custom_object_scope', 'deserialize_keras_object', 'get_custom_objects', 'get_file', 'get_registered_name', 'get_registered_object', 'get_source_inputs', 'model_to_dot', 'multi_gpu_model', 'normalize', 'pack_x_y_sample_weight', 'plot_model', 'register_keras_serializable', 'serialize_keras_object', 'to_categorical', 'unpack_x_y_sample_weight']

from keras-io.

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.