Tag Archives: ImportError: cannot import name ‘np_utils‘ from ‘tensorflow.keras.utils‘

ImportError: cannot import name’e.g. utils’from’tensorflow.as.utils’ 38382;’ 39064;

My blog will be synchronized to the oschina community soon. This is my oschina ID: little white rabbit Dy, please join us: https://www.oschina.net/sharing-plan/apply

We encountered a problem when we reproduced the code. Import from tensorflow.keras.utils import NP_ Utils will report an error. The following problems occurred:

cannot import name ‘np_ utils’ from ‘tensorflow.keras.utils’ (C:\Software\Anaconda3\envs\machine\lib\site-packages\tensorflow_ core\python\keras\api_ v2\keras\utils_ init_. py)

Solution:

Due to the upgrade of the keras version, the__ init__. Py, we can see that the package migration results in the installation of NP in anaconda_ Utils package, still can’t be imported. Take the to I want to use_ Take categorical as an example

1. Change the import statement to: 1

from tensorflow.python.keras.utils.np_ utils import to_ categorical

As shown in the figure:

2. Put the required sentences here

Delete the preceding

np_ utils.

As shown in the figure:

No error in running result:

This article shares CSDN – little white rabbit dy.