I'm having problem with tensorflow. I want to use ImageDataGenerator, but I'm receiving error ModuleNotFoundError: No module named 'tf'. Not sure what is the problem. I added this tf.version to test will it work, and it shows the version of tensorflow.
import tensorflow as tf
from tensorflow import keras
print(tf.__version__)
from tf.keras.preprocessing.image import ImageDataGenerator
When I run this code, I get this:
2.1.0
Traceback (most recent call last):
File "q:/TF/Kamen papir maaze/rks.py", line 14, in <module>
from tf.keras.preprocessing.image import ImageDataGenerator
ModuleNotFoundError: No module named 'tf'
The line
import tensorflow as tf
means you are importing tensorflow with an alias as tf to call it modules/functions.
You cannot use the alias to import other modules.
For your case, if you call directly
tf.keras.preprocessing.image.ImageDataGenerator(...)
then it will work.
or
you need to import the module with the right module name. i.e.
from tensorflow.keras.preprocessing.image import ImageDataGenerator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With