ImportError: 找不到名为 'keras.utils.visualize_util' 的模块。

15

嗨,当我尝试在Keras中运行代码时,它显示以下错误:

from keras.utils.visualize_util import plot
ImportError: No module named 'keras.utils.visualize_util'

我该如何解决这个问题?谢谢。

4个回答

39

您需要手动修复代码或降级Keras。

通过查看该模块的提交历史记录,您可以看到它在2017年2月28日从visualize_util更名为vis_utilsplot函数也被重命名为plot_model

您需要更新代码以反映这些更改,或使用一个适当的Keras版本,在该版本中开发或测试您正在使用的代码。


非常感谢您。您帮了我很多。 - S.EB

15

TensorFlow 2:

from tensorflow.keras.utils import plot_model

3

Use

from keras.utils import plot_model

instead


1

使用以下代码替代:

from tensorflow.python.keras.utils.np_utils import to_categorical


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接