Python Keras:打印模型时发生断言错误
我想使用下面的函数绘制我的Keras模型。每次我尝试这样做时,它都会给我以下断言错误。有人能帮忙吗Python Keras:打印模型时发生断言错误,python,tensorflow,plot,keras,pydot,Python,Tensorflow,Plot,Keras,Pydot,我想使用下面的函数绘制我的Keras模型。每次我尝试这样做时,它都会给我以下断言错误。有人能帮忙吗 --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-37-4e7b8789844d> in <mod
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-37-4e7b8789844d> in <module>
9
10 model,_ = create_model()
---> 11 plot_keras_model(model, show_shapes=True, show_layer_names=False)
<ipython-input-37-4e7b8789844d> in plot_keras_model(model, show_shapes, show_layer_names)
6 from keras.utils.vis_utils import model_to_dot
7 def plot_keras_model(model, show_shapes=True, show_layer_names=True):
----> 8 return SVG(model_to_dot(model, show_shapes=show_shapes, show_layer_names=show_layer_names, expand_nested=True).create(prog='dot',format='svg'))
9
10 model,_ = create_model()
/opt/conda/lib/python3.6/site-packages/keras/utils/vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir, expand_nested, dpi, subgraph)
180 if not is_model(layer) and (
181 not is_wrapped_model(layer)):
--> 182 assert dot.get_node(inbound_layer_id)
183 assert dot.get_node(layer_id)
184 dot.add_edge(pydot.Edge(inbound_layer_id,
AssertionError:
我们能知道什么是断言错误吗?或者它是不完整的吗?@neel g:断言错误是不完整的。上面的错误信息就是我所得到的。我们能知道什么是断言错误,还是它不完整吗?@neel g:断言错误不完整。我只收到上面的错误消息。。
import pydotplus as pydot
from IPython.display import SVG
from keras.utils.vis_utils import model_to_dot
def plot_keras_model(model, show_shapes=True, show_layer_names=True):
return SVG(model_to_dot(model, show_shapes=show_shapes, show_layer_names=show_layer_names).create(prog='dot',format='svg'))
model,_ = create_model()
plot_keras_model(model, show_shapes=True, show_layer_names=False)