Keras Visualizer
A Python Library for Visualizing Keras Models.
Table of Contents
Installation
Install
Use python package manager (pip) to install Keras Visualizer.
pip install keras-visualizer
Upgrade
Use python package manager (pip) to upgrade Keras Visualizer.
pip install keras-visualizer --upgrade
Usage
from keras_visualizer import visualizer
# create your model here
# model = ...
visualizer(model, file_format='png')
Parameters
visualizer(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 :
- set
file_format='png'orfile_format='pdf'to save visualization file.- use
view=Trueto open visualization file.- use settings to customize output image.
Settings
you 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 names here.
from keras_visualizer import visualizer
my_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)
Examples
you can use simple examples as .py or .ipynb format in examples directory.
Example 1
from keras import models, layers
from keras_visualizer import visualizer
model = 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 2
from keras import models, layers
from keras_visualizer import visualizer
model = 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 3
from keras import models, layers
from keras_visualizer import visualizer
model = 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 layers
-
Core layers
- Input object
- Dense layer
- Activation layer
- Embedding layer
- Masking layer
- Lambda layer
-
Convolution layers
- Conv1D layer
- Conv2D layer
- Conv3D layer
- SeparableConv1D layer
- SeparableConv2D layer
- DepthwiseConv2D layer
- Conv1DTranspose layer
- Conv2DTranspose layer
- Conv3DTranspose layer
-
Pooling layers
- MaxPooling1D layer
- MaxPooling2D layer
- MaxPooling3D layer
- AveragePooling1D layer
- AveragePooling2D layer
- AveragePooling3D layer
- GlobalMaxPooling1D layer
- GlobalMaxPooling2D layer
- GlobalMaxPooling3D layer
- GlobalAveragePooling1D layer
- GlobalAveragePooling2D layer
- GlobalAveragePooling3D layer
-
Reshaping layers
- Reshape layer
- Flatten layer
- RepeatVector layer
- Permute layer
- Cropping1D layer
- Cropping2D layer
- Cropping3D layer
- UpSampling1D layer
- UpSampling2D layer
- UpSampling3D layer
- ZeroPadding1D layer
- ZeroPadding2D layer
- ZeroPadding3D layer
-
Regularization layers
- Dropout layer
- SpatialDropout1D layer
- SpatialDropout2D layer
- SpatialDropout3D layer
- GaussianDropout layer
- GaussianNoise layer
- ActivityRegularization layer
- AlphaDropout layer
Metadata
Release files for keras-visualizer 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keras_visualizer-3.2.0.tar.gz | 613.6 kB | Without provenance | Details for keras_visualizer-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keras_visualizer-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for keras_visualizer-3.2.0-py3-none-any.whl |
Total release size: 620.7 kB
Release files / keras_visualizer-3.2.0.tar.gz
| Download URL | keras_visualizer-3.2.0.tar.gz |
|---|---|
| Size | 613.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b175e62958ca4ae1733c57fc11d983a0907a0e78367da42705d9375f86fa503
|
|
BLAKE2b-256 checksum How to use checksums |
16e609f94c01993ddac9ff66ca5933b3a0b0b057431d6c5c1b35c3474c90722d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / keras_visualizer-3.2.0-py3-none-any.whl
| Download URL | keras_visualizer-3.2.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28236f7726a560da8063b6db348dc162088770fdd46601d88666a87bf2c0b869
|
|
BLAKE2b-256 checksum How to use checksums |
c807717bc527b756b10e60dcbdd5b457a0adb6df3315e0d3845fe05c7c22d772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for keras-visualizer 3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.