我正在尝试在keras中使用to_categorical方法将我的变量转换为categorical并面临问题

时间:2019-01-28 10:15:31

标签: tensorflow keras

我尝试卸载并重新安装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>()

1 个答案:

答案 0 :(得分:0)

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

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

pip install np_utils
安装后

重新启动内核。