import tensorflow as tf tf.__version__ !sudo pip3 install keras from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2D from tensorflow.keras.preprocessing.image import ImageDataGeneratorMensaje de error:
Import "tensorflow.keras.models" could not be resolved(reportMissingImports) >Import "tensorflow.keras.layers" could not be resolved(reportMissingImports) >>Import "tensorflow.keras.preprocessing.image" could not be resolved(reportMissingImports)Asunto resuelto.
Aunque el mensaje de error: Import "tensorflow.keras.models" could not be resolved(reportMissingImports) , no afecta a todo el código. Mi versión de Tensorflow es 2.8.0. Acabo de descubrir que el problema está en la configuración de mi modelo cnn.
import tensorflow as tf tf.__version__ !sudo pip3 install keras from tensorflow.python.keras.engine.sequential import Sequential from tensorflow.python.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2D image_data_generator = tf.keras.preprocessing.image.ImageDataGenerator()tuve el mismo error, hice esos pasos paso 01 : desinstale el tensorflow existente con esta instrucción
!pip uninstall tensorflowpaso 02: instale esta versión espero que encuentre lo que necesita en esta versión con esta instrucción
!pip install tensorflow==2.7.0puede cambiar la versión de tensorflow si 2.7.0 no es bueno para su código