我试图在keras中使用to_categorical方法将我的变量转换为分类并面对问题

问题描述 投票:0回答:1

我尝试卸载并重新安装Keras,Tensorflow并没有找到任何解决方案。

    from keras.utils.np_utils import to_categorical
    Y_train = to_categorical(y_train, num_classes=None)
    Y_test = to_categorical(y_test, num_classes=None)
    print(Y_train.shape)
    ImportError                               Traceback (most recent call last)
    ~\Anaconda3\envs\nnet\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
         57 
    ---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
         59   from tensorflow.python.pywrap_tensorflow_internal import __version__

    ImportError: DLL load failed: The specified module could not be found.

    During handling of the above exception, another exception occurred:

    ImportError                               Traceback (most recent call last)
    <ipython-input-6-3cac28c3a2f2> in <module>()
tensorflow keras
1个回答
0
投票

对于keras较新的keras版本使用from keras.utils import to_categorical

如果您有较旧的keras尝试使用以下命令安装np_utils:

pip install np_utils

并在安装后重新启动内核。

© www.soinside.com 2019 - 2024. All rights reserved.