Windows10中Keras可視化的坑(已解決)
前言
爲了將RNN和LSTM的結構可視化,我也算是操碎了心。
網上一些大佬們的教程也算是幫了很多忙,但是仍然解決不了問題,後來在羣裏問了一下,一位大佬點了一句:
可能是pip安裝GraphViz的版本不對,用conda試試,巧了,我剛好成功了。
參考教程:
- https://blog.csdn.net/sinat_37998852/article/details/80507536
- https://blog.csdn.net/u013250416/article/details/72790754
任務目標:
需要在Keras中使用這一句:
plot_model(model, to_file='model.png')
因此需要導入plot_model這個函數;
這個函數這樣導入:
from keras.utils import plot_model
導入會報錯:
ImportError: Failed to import `pydot`. Please install `pydot`. For example with `pip install pydot`. #69
這時候你需要查教程了:
先看這個就好了:
pydot 和graphviz配置出錯及幾種解決方法(已解決)
1、確保安裝順序正確:
graphviz->grapphviz軟件本身->pydot
(https://www.jianshu.com/p/f3a0b2ca0ca8)
首先要在python中安裝graphviz:pip install graphviz;
然後下載graphviz這個軟件,直接下載鏡像文件安裝就好(安裝蠻簡單的,有人說c盤會有權限,反正你別裝c盤就好,我在d盤成功的,且用戶是所有人),要記得安裝路徑,並將路徑添加到系統path中——
最後,pip install pydot。
然後你也許會發現這樣的報錯:
OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.
這時候換到終端下:
用conda重新安裝GraphViz就好了——
conda install GraphViz
效果圖:
其實還不如model.summary()
提供的信息有用呢!