从keras.utils.np_utils import to_categorical ModuleNotFoundError:No module named 'keras.utils.np_utils'

nwwlzxa7  于 11个月前  发布在  Go
关注(0)|答案(1)|浏览(157)

我尝试从keras运行下面的示例
但我得到了这个错误:

C:\Users\ANJALI\OneDrive\Desktop\Project\Minor Project\Minor_HelmetDetection\HelmetDetection>py HelmetDetection.py
2023-11-24 15:00:37.549028: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
WARNING:tensorflow:From C:\Users\ANJALI\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

Traceback (most recent call last):
  File "C:\Users\ANJALI\OneDrive\Desktop\Project\Minor Project\Minor_HelmetDetection\HelmetDetection\HelmetDetection.py", line 19, in <module>
    from keras.utils.np_utils import to_categorical
ModuleNotFoundError: No module named 'keras.utils.np_utils'

字符串
我试着更新库,但仍然没有变化

mf98qq94

mf98qq941#

使用而不是下面的行,

import keras.utils.np_utils

字符串
代码:

from keras.utils import to_categorical


它会成功的

相关问题