Adelovi
Adelovi

Reputation: 95

Can't import 'HDF5Matrix' from keras.utils

I am using Google Colab, and i tried to import HDF5Matrix class from keras.utils or keras.utils..io_utils, but i keep getting an error as you can see in the picture below:

The error is :

ImportError: cannot import name 'HDF5Matrix' from 'tensorflow.keras.utils' (/usr/local/lib/python3.7/dist-packages/tensorflow/keras/utils/__init__.py)

enter image description here

Upvotes: 0

Views: 2975

Answers (1)

simpleApp
simpleApp

Reputation: 3158

I think you are on 2.4.1.

print(tf.version.VERSION) # 2.4.1

As a workaround:

pls try to go to the previous version and it should work okay.

!pip install tensorflow==2.3.1 # install 2.3.1
import os

import tensorflow as tf
from tensorflow import keras

print(tf.version.VERSION)
from tensorflow.keras.utils import HDF5Matrix

Upvotes: 2

Related Questions