A python package to visualize sequentail tensorflow model archtictures
Project description
Litten
Litten is a python package to visualize sequential Tensorflow(keras) neural network model architectures, Get layers summary in details, visualize conv layers filters and featurmaps.
Installation
To install latest version from PyPi
$ pip install litten
How to use it?
- Create your neural network archtictures
model = keras.models.Sequential(
[
keras.layers.Conv2D(filters = 32, kernel_size = 3, input_shape = [150, 150, 3]),
...
keras.layers.Dense(units = 2, activation = 'softmax')
]
)
# or using functional API
input = keras.Input(shape=(28, 28, 1), name="img")
...
output = keras.layers.Dense(units = 2, activation = 'softmax')(x)
model = keras.Model(input, output, name="Model")
- Import LayersSummary, ModelVisualizer and create objects
from litten import LayersSummary, ModelVisualizer
- To get Layers Summaries
summary = LayersSummary()
summary.show_layers_summaries(model)
Output:
=================================================================================================================
Layer 1: InputLayer | Attributes
----------------------------------------
built : True
sparse : False
ragged : False
batch_size : None
is_placeholder : True
=================================================================================================================
Layer 2: Conv2D | Attributes
----------------------------------------
rank : 2
filters : 16
groups : 1
kernel_size : (3, 3)
strides : (1, 1)
padding : valid
data_format : channels_last
dilation_rate : (1, 1)
activation : <function relu at 0x7f6b7038fee0>
use_bias : True
kernel_initializer : <keras.initializers.initializers_v2.GlorotUniform object at 0x7f6aee189610>
bias_initializer : <keras.initializers.initializers_v2.Zeros object at 0x7f6aee189af0>
kernel_regularizer : None
bias_regularizer : None
kernel_constraint : None
bias_constraint : None
built : True
=================================================================================================================
....
-
To visualize model architecture
ModelVisualizer.visualize_model( show_names=False, show_properties=False, show_connectors=False, pallete='default' )Example 1
vis = ModelVisualizer(model) vis.visualize_model()
Example 2
vis.visualize_model(show_names=True)
Example 3
vis.visualize_model(show_names=True, show_connectors = True)
Exampel 4
vis.visualize_model(show_names=True, show_connectors = True, show_properties=True)
Example 5 You can choose one from these palettes
default,red,green,blue,yellow,brown,purple,grayvis.visualize_model(show_names=True, show_connectors=True, palette=<palette>)
-
To visualize Conv filters
ModelVisualizer.visualize_filters( cmap = 'gray' # matplotlib cmaps )Example
vis = ModelVisualizer(model) vis.visualize_filters('Blues')
-
To visualize Features map
ModelVisualizer.visualize_featuremap( input_image, cmap = 'gray' # matplotlib cmaps )Example
vis = ModelVisualizer(model) vis.visualize_featuremap(input_image, 'Blues')
Contributing to litten
To contribute to litten, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>. - Make your changes and commit them:
git commit -m '<commit_message>' - Push to the original branch:
git push origin <project_name>/<location> - Create the pull request.
Alternatively see the GitHub documentation on creating a pull request.
License
Open source licensed under the MIT license (see LICENSE file for details).
Tools
- Python
- PIL
- Matplotlib
- pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litten-0.1.0.tar.gz.
File metadata
- Download URL: litten-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d3135de7c89ee9dfb901ed18cf82835b88d6fc24a0856076f21ee85be36b323
|
|
| MD5 |
de1e75cf9439aeab7ca58bcbda643f32
|
|
| BLAKE2b-256 |
ee52f747eb5c982120bb1630a22e7dada4ec720ca38f61abb62f5931a168b177
|
File details
Details for the file litten-0.1.0-py3-none-any.whl.
File metadata
- Download URL: litten-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaffd13a7444d4df44b52317f018e7d6bb397b1f8ce0b0c26cd515dc3c0f59d3
|
|
| MD5 |
32007b1a7a4d757e570459de4ff64332
|
|
| BLAKE2b-256 |
f559ef367da99633b72c060911ae78ba3c3156f583b5af005209b0b2dd269b8b
|