Skip to main content

tf2show prints tensorflow2's keras model pretty.

Project description

tf2show

Install

pip install tf2show

Example

import tensorflow as tf
from tf2show import tf2show

model = tf.keras.applications.ResNet50()
tf2show(model)	# show model structure
tf2show(model,"model.xlsx")    # save model structure as excel file

Description

tf2show prints tensorflow2's keras model pretty.

Below is the result of summary function provided in tensorflow2.

It's not pretty. In addition, some output has been omitted.

Model: "mobilenet_1.00_256"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         [(None, 256, 256, 3)]     0         
_________________________________________________________________
conv1_pad (ZeroPadding2D)    (None, 257, 257, 3)       0         
_________________________________________________________________
conv1 (Conv2D)               (None, 128, 128, 32)      864       
_________________________________________________________________
conv1_bn (BatchNormalization (None, 128, 128, 32)      128       
_________________________________________________________________
conv1_relu (ReLU)            (None, 128, 128, 32)      0         
_________________________________________________________________
conv_dw_1 (DepthwiseConv2D)  (None, 128, 128, 32)      288       
_________________________________________________________________
.
.
.
_________________________________________________________________
reshape_2 (Reshape)          (None, 1000)              0         
_________________________________________________________________
predictions (Activation)     (None, 1000)              0         
=================================================================
Total params: 4,253,864
Trainable params: 4,231,976
Non-trainable params: 21,888
_________________________________________________________________

Below is the output using tf2show.

It's pretty. All names are printed.

----------------------------------------------------------------------------------------------------
| LAYER                  | NAME                     | C    | H   | W    | INPUTS                   |
----------------------------------------------------------------------------------------------------
| InputLayer             | input_1                  | 3    | 256 | 256  | input_1:0                |
| ZeroPadding2D          | conv1_pad                | 3    | 257 | 257  | input_1:0                |
| Conv2D                 | conv1                    | 32   | 128 | 128  | conv1_pad                |
| BatchNormalization     | conv1_bn                 | 32   | 128 | 128  | conv1                    |
| ReLU                   | conv1_relu               | 32   | 128 | 128  | conv1_bn                 |
| DepthwiseConv2D        | conv_dw_1                | 32   | 128 | 128  | conv1_relu               |
| BatchNormalization     | conv_dw_1_bn             | 32   | 128 | 128  | conv_dw_1                |
| ReLU                   | conv_dw_1_relu           | 32   | 128 | 128  | conv_dw_1_bn             |
| Conv2D                 | conv_pw_1                | 64   | 128 | 128  | conv_dw_1_relu           |
| BatchNormalization     | conv_pw_1_bn             | 64   | 128 | 128  | conv_pw_1                |
| ReLU                   | conv_pw_1_relu           | 64   | 128 | 128  | conv_pw_1_bn             |
| ZeroPadding2D          | conv_pad_2               | 64   | 129 | 129  | conv_pw_1_relu           |
| DepthwiseConv2D        | conv_dw_2                | 64   | 64  | 64   | conv_pad_2               |
.
.
.
| Reshape                | reshape_2                |      |     | 1000 | conv_preds               |
| Activation             | predictions              |      |     | 1000 | reshape_2                |
----------------------------------------------------------------------------------------------------

It also supports saving to Excel.

This function can be useful when analyzing models.

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

tf2show-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tf2show-0.0.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file tf2show-0.0.3.tar.gz.

File metadata

  • Download URL: tf2show-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tf2show-0.0.3.tar.gz
Algorithm Hash digest
SHA256 54d8e6f8db7c3c39fc95320c48894b0568c365a2dcf62db27aea9ce62739f69e
MD5 76bbf0815384a3e69edfdf32e4108b6d
BLAKE2b-256 c6b2994855a30e7075beb5cc4d58242b9fd3a2e1d69d2e52644f3a36fedab8ad

See more details on using hashes here.

File details

Details for the file tf2show-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tf2show-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tf2show-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 db40698d602d510f70938daffb3589a936fa0836b8ff10577526ab86a58b727d
MD5 07519105d70aab55df360eeadaa848fe
BLAKE2b-256 f287385642be9cfcea275859c54cef9e1586669ef41d799e3b5afcb3773e94f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page