简体   繁体   中英

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

"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". And before you what version I am using. I am using tensorflow 2.4.1.

What am I doing wrong?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM