We Are Going To Discuss About AttributeError: module ‘keras.utils’ has no attribute ‘to_categorical’. So lets Start this Python Article.
AttributeError: module ‘keras.utils’ has no attribute ‘to_categorical’
- How to solve AttributeError: module 'keras.utils' has no attribute 'to_categorical'
Newer versions of keras==2.4.0 and tensorflow==2.3.0 would work as follows
so use:from keras.utils import np_utils
and then replacekeras.utils.to_categorical
withkeras.utils.np_utils.to_categorical
- AttributeError: module 'keras.utils' has no attribute 'to_categorical'
Newer versions of keras==2.4.0 and tensorflow==2.3.0 would work as follows
so use:from keras.utils import np_utils
and then replacekeras.utils.to_categorical
withkeras.utils.np_utils.to_categorical
Solution 1
Newer versions of keras==2.4.0 and tensorflow==2.3.0 would work as follows
so use:
from keras.utils import np_utils
and then replace keras.utils.to_categorical
with
keras.utils.np_utils.to_categorical
Original Author Eng Adam Al mohammedi Of This Content
Solution 2
U can also use from tensorflow.keras.utils import to_categorical
this error pops up for a lot of attributes.
Sometimes, clearly importing the attribute also helps, but in this case; you have to specify tensorflow.keras
Original Author Anshuman Tekriwal Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.