LoginSignup
6
3

More than 3 years have passed since last update.

JupyterでSVGを使った際に表示が見切れる

Last updated at Posted at 2020-06-30

新しい開発環境で以下のようにSVGを使って深層学習のネットワーク構造をいつも通り可視化しようとしたところ、図のように表示が見切れてしまった。

from IPython.display import SVG

from keras.utils.vis_utils import model_to_dot
SVG(model_to_dot(model, show_shapes=True).create(prog='dot', format='svg'))

Screenshot from 2020-06-30 23-46-11.png

調べてみたところ、バージョン1.14.0以降のkerasのmodel_to_dot関数の引数にdpiが加わり、デフォルト値が96に設定されているのが問題のようです。
もともとはNoneとして扱われていたようなのでmodel_to_dotの引数にdpi=Noneを加えてあげましょう。

SVG(model_to_dot(model, show_shapes=True, dpi=None).create(prog='dot', format='svg'))

Screenshot from 2020-07-01 00-09-22.png

これで表示することが可能です。
なお、dpiを変えれば自由にサイズを変えることができます。

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3