Cannot import name 'preprocessing' from 'tensorflow.keras.experimental in tensor flow 2.4.1?

Question:

import tensorflow as tf

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.experimental import preprocessing

When I run the code above. I get:

ImportError: cannot import name ‘preprocessing’ from
‘tensorflow.keras.experimental".

Note, I am using TensorFlow 2.4.1.

What am I doing wrong?

Asked By: Greg Himphminky

||

Answers:

It’s because you’re using the wrong import. Try changing

from tensorflow.keras.experimental import preprocessing

to

from tensorflow.keras.layers.experimental import preprocessing
Answered By: enzo
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.