how to visualize the DNN or CNN model with the values of the input and output layers?

367 Views Asked by At

I have applied visualization to the DNN model, but the image just contains a dense layer Without the value of the input and output layers! The code below explains the visualization process without any error, I tried to show the values of the input and output layers in image.

import pandas as pd
.
. 
tf.keras.utils.plot_model
.
.
def create_model():

model = Sequential()
model.add(Input(n_features))
model.add(BatchNormalization())
model.add(Dense(51, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(68, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(85, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(85, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(68, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(51, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(n_outputs, activation='sigmoid'))
model.compile(loss='binary_crossentropy', 
              optimizer='Adam', 
              metrics=['accuracy'])
tf.keras.utils.plot_model(model, to_file='model_combined.png')
#model.summary()
return model    

#I have tried to use 
#from keras.utils.vis_utils import plot_model
# but i found this error : TypeError: 'InputLayer' object is not iterable
# so i use the above library to implement visualization without any error.

Please note that I have downloaded all of these libraries: Graphviz, pydot, pydotplus, python-graphviz

1

There are 1 best solutions below

0
Rezuana Haque On

Have you tried Netron app? It can be used to visualize the DNN or CNN model with the values of the input and output layers.

Here you can find all the details