Package: keras-visualizer
Keras VisualizerA Python Library for Visualizing Keras Models.Table of ContentsKeras VisualizerTable of ContentsInstallationInstallUpgradeUsageParametersSettingsExamplesExample 1Example 2Example 3Supported layersInstallationInstallUse python package manager (pip) to install Keras Visualizer.pipinstallkeras-visualizerUpgradeUse python package manager (pip) to upgrade Keras Visualizer.pipinstallkeras-visualizer--upgradeUsagefromkeras_visualizerimportvisualizer# create your model here# model = ...visualizer(model,file_format='png')Parametersvisualizer(model,file_name='graph',file_format=None,view=False,settings=None)model: a Keras model instance.file_name: where to save the visualization.file_format: file format to save 'pdf', 'png'.view: open file after process if True.settings: a dictionary of available settings.Note :setfile_format='png'orfile_format='pdf'to save visualization file.useview=Trueto open visualization file.usesettingsto customize output image.Settingsyou can customize settings for your output image. here is the default settings dictionary:settings={# ALL LAYERS'MAX_NEURONS':10,'ARROW_COLOR':'#707070',# INPUT LAYERS'INPUT_DENSE_COLOR':'#2ecc71','INPUT_EMBEDDING_COLOR':'black','INPUT_EMBEDDING_FONT':'white','INPUT_GRAYSCALE_COLOR':'black:white','INPUT_GRAYSCALE_FONT':'white','INPUT_RGB_COLOR':'#e74c3c:#3498db','INPUT_RGB_FONT':'white','INPUT_LAYER_COLOR':'black','INPUT_LAYER_FONT':'white',# HIDDEN LAYERS'HIDDEN_DENSE_COLOR':'#3498db','HIDDEN_CONV_COLOR':'#5faad0','HIDDEN_CONV_FONT':'black','HIDDEN_POOLING_COLOR':'#8e44ad','HIDDEN_POOLING_FONT':'white','HIDDEN_FLATTEN_COLOR':'#2c3e50','HIDDEN_FLATTEN_FONT':'white','HIDDEN_DROPOUT_COLOR':'#f39c12','HIDDEN_DROPOUT_FONT':'black','HIDDEN_ACTIVATION_COLOR':'#00b894','HIDDEN_ACTIVATION_FONT':'black','HIDDEN_LAYER_COLOR':'black','HIDDEN_LAYER_FONT':'white',# OUTPUT LAYER'OUTPUT_DENSE_COLOR':'#e74c3c','OUTPUT_LAYER_COLOR':'black','OUTPUT_LAYER_FONT':'white',}Note:set'MAX_NEURONS': Noneto disable max neurons constraint.see list of color nameshere.fromkeras_visualizerimportvisualizermy_settings={'MAX_NEURONS':None,'INPUT_DENSE_COLOR':'teal','HIDDEN_DENSE_COLOR':'gray','OUTPUT_DENSE_COLOR':'crimson'}# model = ...visualizer(model,file_format='png',settings=my_settings)Examplesyou can use simple examples as.pyor.ipynbformat inexamples directory.Example 1fromkerasimportmodels,layersfromkeras_visualizerimportvisualizermodel=models.Sequential([layers.Dense(64,activation='relu',input_shape=(8,)),layers.Dense(6,activation='softmax'),layers.Dense(32),layers.Dense(9,activation='sigmoid')])visualizer(model,file_format='png',view=True)Example 2fromkerasimportmodels,layersfromkeras_visualizerimportvisualizermodel=models.Sequential()model.add(layers.Conv2D(64,(3,3),input_shape=(28,28,3),activation='relu'))model.add(layers.MaxPooling2D((2,2)))model.add(layers.Flatten())model.add(layers.Dense(3))model.add(layers.Dropout(0.5))model.add(layers.Activation('sigmoid'))model.add(layers.Dense(1))visualizer(model,file_format='png',view=True)Example 3fromkerasimportmodels,layersfromkeras_visualizerimportvisualizermodel=models.Sequential()model.add(layers.Embedding(64,output_dim=256))model.add(layers.LSTM(128))model.add(layers.Dense(1,activation='sigmoid'))visualizer(model,file_format='png',view=True)Supported layersExplore list ofkeras layersCore layersInput objectDense layerActivation layerEmbedding layerMasking layerLambda layerConvolution layersConv1D layerConv2D layerConv3D layerSeparableConv1D layerSeparableConv2D layerDepthwiseConv2D layerConv1DTranspose layerConv2DTranspose layerConv3DTranspose layerPooling layersMaxPooling1D layerMaxPooling2D layerMaxPooling3D layerAveragePooling1D layerAveragePooling2D layerAveragePooling3D layerGlobalMaxPooling1D layerGlobalMaxPooling2D layerGlobalMaxPooling3D layerGlobalAveragePooling1D layerGlobalAveragePooling2D layerGlobalAveragePooling3D layerReshaping layersReshape layerFlatten layerRepeatVector layerPermute layerCropping1D layerCropping2D layerCropping3D layerUpSampling1D layerUpSampling2D layerUpSampling3D layerZeroPadding1D layerZeroPadding2D layerZeroPadding3D layerRegularization layersDropout layerSpatialDropout1D layerSpatialDropout2D layerSpatialDropout3D layerGaussianDropout layerGaussianNoise layerActivityRegularization layerAlphaDropout layer