Skip to main content

A usefull CNN/DenseNet visualization tool

Project description

neural-network-renderer

The code generating the image is writen in Python. This code generates .tex and .sty files that are directly compiled and deleted once the resulting PDF is available.

Example

Here is an example of the code to generate a simple convolutionnal-network representation:

from neural_network_renderer.architecture import Architecture
from neural_network_renderer.colors import Colors
from neural_network_renderer.layers import Conv, ConvConvRelu, Dense, DottedLines, Input, Pool, Softmax, Spacer

def main():
    Colors.Dense("lightgray")
    Colors.Softmax("lightgray")

    arch = Architecture(4 / 32)
    # first layer
    arch.add(ConvConvRelu(s_filter=64, n_filter=[32, 32], to="(5,0,0)"))
    arch.add(Pool([32, 32, 32]))
    arch.add(Spacer(width=20))

    # second layer
    arch.add(ConvConvRelu(s_filter=32, n_filter=[64, 64]))
    arch.add(Pool([16, 16, 64]))

    arch.add(Spacer())

    # third layer
    arch.add(ConvConvRelu(s_filter=16, n_filter=[64, 64]))
    arch.add(Pool([8, 8, 64], name="last_pool"))
    arch.add(Spacer())

    # GPA
    arch.add(Conv(s_filter=8, n_filter=1, name="gpa", caption="GPA"))

    # flatten
    arch.add(Dense(64, name="flatten", offset="(4,0,0)", caption="Hidden Layer"))
    arch.add(Softmax(5, 5, name="output", caption="Output", offset="(4,0,0)"))

    arch.add(DottedLines("gpa", "flatten"))
    arch.add(DottedLines("flatten", "output"))

    arch.to_pdf("output_file")


if __name__ == "__main__":
    main()

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

neural_network_renderer-0.2.5.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file neural_network_renderer-0.2.5.tar.gz.

File metadata

  • Download URL: neural_network_renderer-0.2.5.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for neural_network_renderer-0.2.5.tar.gz
Algorithm Hash digest
SHA256 0c085344e5bba44f8c24e84b217f068f4a6121b9b11ad38b616334dd0b6d97b3
MD5 62c81a35456312e18d23821684e9d64d
BLAKE2b-256 dc16e0cfd8dad791412652de0f17f6a3cb89e0f4f8467f23dbb8ac803f22d1ec

See more details on using hashes here.

Supported by

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