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.
Similar Posts:
- Error reporting of importing tensorflow package from pycharm
- Keras.utils.to in keras_ Categorical method
- [Solved] Python TensorFlow Error: ‘tensorflow.compat.v2.__internal__’ has no attribute ‘tf2’
- Error in importing tensorflow in Jupiter Notebook: no module named tensorflow solution
- jupyter notebook error: No module named ‘tensorflow’
- Conda Install Library Error: failed with initial frozen solve. Retrying with flexible solve.
- [Solved] Tensorflow:ImportError: DLL load failed: The specified module cannot be found Failed to load the native TensorFlow runtime
- [Solved] Error caused by correspondence between tensorflow GPU version number and CUDA
- [Solved] ImportError: cannot import name pywrap_tensorflow
- After tensorflow is installed, an error occurred during import: importerror: DLL load failed: the specified module cannot be found