• 'Failed to import pydot. You must `pip install pydot` and install graphviz


    import pydot
    import graphviz
    from keras.utils import plot_model
    plot_model(model, to_file='model.png')


    ('Failed to import pydot. You must `pip install pydot` and install graphviz (https://graphviz.gitlab.io/download/), ', 'for `pydotprint` to work.')



    conda install -c https://conda.binstar.org/t/TOKEN/j14r pydot
    conda install -c https://conda.binstar.org/t/TOKEN/j14r graphviz


     I used pip uninstall on all related packages, then:

    pip install pydot
    pip install pydotplus
    pip install graphviz
    pip install pydot-ng

    Then:

    • Download and install graphviz binaries from here
    • Add path to graphviz bin folder in system PATH

    Using TensorFlow 2.3.0 on Windows 10 without Anaconda, the following (finally) worked for me:

    1. Install Graphviz 32 bit (64 bit didn't work)
    2. Add Graphviz path C:Program Files (x86)Graphvizin to system's and user's PATH environment variables
    3. Install pydot-ng which is the preferred pydot library used by TensorFlow 2.3.0
    
    
    import keras
    import pydot
    import pydotplus
    from pydotplus import graphviz
    from keras.utils.vis_utils import plot_model
    from keras.utils.vis_utils import model_to_dot
    keras.utils.vis_utils.pydot = pydot



    REF
    https://stackoverflow.com/questions/47605558/importerror-failed-to-import-pydot-you-must-install-pydot-and-graphviz-for-py

     import tensorflow as tf
    
      input = tf.keras.Input(shape=(100,), dtype='int32', name='input')
    
      x = tf.keras.layers.Embedding(output_dim=512, input_dim=1000, input_length=100)(input)
    
      x = tf.keras.layers.LSTM(32)(x)
    
      x = tf.keras.layers.Dense(64, activation='relu')(x)
    
      output = tf.keras.layers.Dense(1, activation='sigmoid', name='output')(x)
    
      model = tf.keras.Model(inputs=[input], outputs=[output])

     

     REF

    https://www.gcptutorials.com/article/how-to-plot-model-architecture-with-tf.keras.utils








  • 相关阅读:
    前端开发聚合
    6. webRTC
    14.移动端图片浏览组件 react-wx-images-viewer
    windows下怎样使用md命令一次建立多级子目录
    mysql打印输出转csv格式
    Java Stream简介, 流的基本概念
    Linux使用Shell脚本实现ftp的自动上传下载
    在Linux中设置UMASK值
    SFTP+OpenSSH+ChrootDirectory设置
    导出php5.4支持的数组格式,即以[]为标识符而不是以array()标识
  • 原文地址:https://www.cnblogs.com/emanlee/p/14484116.html
Copyright © 2020-2023  润新知