Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
AttributeError: el módulo 'tensorflow.python.keras.utils.generic_utils' no tiene el atributo 'populate_dict_with_module_objects'

Cuando importo keras, aparece el error anterior a pesar de que ayer funcionaba bien.

¿Cómo resuelvo este error?

Estoy trabajando en Windows 10, mi versión de keras es: 2.2.4, mi versión de tensorflow es: 2.2.0rc2

el seguimiento completo del error se ve a continuación como tal:

 Traceback (most recent call last): from keras import models File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\__init__.py", line 3, in <module> from . import utils File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\__init__.py", line 6, in <module> from . import conv_utils File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module> from .. import backend as K File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\__init__.py", line 1, in <module> from .load_backend import epsilon File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\load_backend.py", line 90, in <module> from .tensorflow_backend import * File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module> import tensorflow as tf File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 84, in <module> from tensorflow.python import keras File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\__init__.py", line 27, in <module> from tensorflow.python.keras import models File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\models.py", line 24, in <module> from tensorflow.python.keras import metrics as metrics_module File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\metrics.py", line 37, in <module> from tensorflow.python.keras.engine import base_layer File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 51, in <module> from tensorflow.python.keras import initializers File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\initializers\__init__.py", line 127, in <module> populate_deserializable_objects() File "C:\Users\world\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\initializers\__init__.py", line 85, in populate_deserializable_objects generic_utils.populate_dict_with_module_objects( AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
over 4 years ago · Santiago Trujillo
17 answers
Answer question

0

Encontré el mismo problema al usar Python 3.9 y Tensorflow 2.5. El problema para mí fue que esos dos aún no son compatibles y, como tal, la solución es instalar python 3.8 en su lugar, y posiblemente también degradar Tensorflow 2.5 a Tensorflow 2.4.

over 4 years ago · Santiago Trujillo Report

0

%env SM_FRAMEWORK=tf.keras

Pruebe este código antes de importar modelos de segmentación, resolvió mi problema.

over 4 years ago · Santiago Trujillo Report

0

Copie la función "populate_dict_with_module_objects" de este enlace (líneas 1162 a 1167) y agréguela a "generic_utils.py"

over 4 years ago · Santiago Trujillo Report

0

cambiar from keras import models from tensorflow.keras import models
esto resolvió el problema para mí con tensorflow 2.5.0

over 4 years ago · Santiago Trujillo Report

0

¡Reemplazó todo de keras a tf.keras !
Uso de libretas:

 tensorflow-cpu==2.4.0 keras==2.4.0
 import tensorflow as tf from tensorflow import keras

Cambiar capas como:

 keras.layers.Conv2D(512, (3, 3), activation='relu', padding='same')(pool4) tf.keras.layers.Conv2D(512, (3, 3), activation='relu', padding='same')(pool4)

Optimizador de cambios:

 keras.optimizers.Adam(lr=1e-5) tf.keras.optimizers.Adam(lr=1e-5)

Operaciones de cambio:

 keras.concatenate tf.concat keras.flatten tf.keras.flatten keras.sum tf.keras.sum

¡Espero que ayude a alguien atrapado allí!

over 4 years ago · Santiago Trujillo Report

0

reemplazar: from keras.utils import generic_utils

con: from tensorflow.python.keras.utils import generic_utils

over 4 years ago · Santiago Trujillo Report

0

Tuve este problema con tensorflow-gpu==2.5.0

Creo que el problema se debe a alguna interacción entre estos dos archivos (env virtual):

 $ find env -name generic_utils.py env/lib/python3.9/site-packages/tensorflow/python/keras/utils/generic_utils.py env/lib/python3.9/site-packages/keras/utils/generic_utils.py

Agregué esta importación a env/lib/python3.9/site-packages/keras/utils/generic_utils.py :

 from tensorflow.python.keras.utils.generic_utils import populate_dict_with_module_objects, to_snake_case

parece trabajado.

Ver aquí: https://github.com/keras-team/keras/issues/14657

over 4 years ago · Santiago Trujillo Report

0

Instalé Tensorflow y Keras usando pip install tensorflow pip install keras y obtuve el mismo error en tensorflow 2.5.0. Desinstalé ambos y los reinstalé con conda install tensorflow conda install keras

Esto resolvió mi error.

over 4 years ago · Santiago Trujillo Report

0

Intenta reemplazar

 tensorflow.python.keras.utils.generic_utils

desde este enlace

over 4 years ago · Santiago Trujillo Report

0

Si usa Google Colab, ejecútelo al comienzo del cuaderno para evitar conflictos con la versión predeterminada proporcionada por Colab. También tenga en cuenta que si tensorflow ya está instalado, reiniciará el tiempo de ejecución. Por lo tanto, es mejor hacer esto al comienzo del cuaderno en lugar de en el medio.

 !pip install tensorflow==2.1.0
over 4 years ago · Santiago Trujillo Report

0

He solucionado esto desinstalando Keras y cambiando todo lo que importo de Keras para importarlo desde tensorflow.keras

Así que esto:

 from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array from keras.applications.vgg16 import preprocess_input from keras.applications.vgg16 import decode_predictions from keras.applications.vgg16 import VGG16

se convirtió en esto:

 from tensorflow.keras.preprocessing.image import load_img from tensorflow.keras.preprocessing.image import img_to_array from tensorflow.keras.applications.vgg16 import preprocess_input from tensorflow.keras.applications.vgg16 import decode_predictions from tensorflow.keras.applications.vgg16 import VGG16

y luego no tuve que enmendar el resto de mi trabajo

over 4 years ago · Santiago Trujillo Report

0

Cambiado from keras.utils import _____

a from tensorflow.python.keras.utils import _____

Esto funcionó para mí mientras usaba TensorFlow 2.5.0

over 4 years ago · Santiago Trujillo Report

0

Intenta usar:

 pip install tensorflow --upgrade --force-reinstall
over 4 years ago · Santiago Trujillo Report

0

Actualicé keras y funcionó. Usé este comando:

 > pip install --upgrade keras

Es posible que deba reiniciar el kernel para ver el efecto.

over 4 years ago · Santiago Trujillo Report

0

En lugar de degradar o cualquier otra solución, importe directamente desde tensorflow.keras

por ejemplo: en lugar de usar: from keras.models import Sequential use: from tensorflow.keras.model import Sequential

over 4 years ago · Santiago Trujillo Report

0

Tuve el mismo problema y lo resolví con éxito al degradar la versión de tensorflow a 2.1.0.

 pip install tensorflow==2.1.0
over 4 years ago · Santiago Trujillo Report

0

intente desinstalar el paquete tf-nightly con este pip uninstall tf-nightly y marque python -c "import tensorflow" . Espero que esto resuelva el problema.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!