Full Code of HarisIqbal88/PlotNeuralNet for AI

master e96bc852189c cached
28 files
86.9 KB
30.4k tokens
21 symbols
1 requests
Download .txt
Repository: HarisIqbal88/PlotNeuralNet
Branch: master
Commit: e96bc852189c
Files: 28
Total size: 86.9 KB

Directory structure:
gitextract_mf86ygiw/

├── .gitignore
├── .idea/
│   ├── misc.xml
│   ├── modules.xml
│   ├── plotneuralnet.iml
│   ├── vcs.xml
│   └── workspace.xml
├── LICENSE
├── README.md
├── examples/
│   ├── AlexNet/
│   │   └── alexnet.tex
│   ├── HED/
│   │   └── HED.tex
│   ├── LeNet/
│   │   ├── lenet.tex
│   │   └── lenet.txt
│   ├── SoftmaxLoss/
│   │   └── SoftmaxLoss.tex
│   ├── Unet/
│   │   └── Unet.tex
│   ├── Unet_Ushape/
│   │   └── Unet_ushape.tex
│   ├── VGG16/
│   │   └── vgg16.tex
│   ├── fcn32s/
│   │   └── fcn32.tex
│   └── fcn8s/
│       └── fcn8.tex
├── layers/
│   ├── Ball.sty
│   ├── Box.sty
│   ├── RightBandedBox.sty
│   └── init.tex
├── pycore/
│   ├── __init__.py
│   ├── blocks.py
│   └── tikzeng.py
├── pyexamples/
│   ├── test_simple.py
│   └── unet.py
└── tikzmake.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.aux
*.log
*.gz

__pycache__
books
project

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.12 (/usr/bin/python2.7)" project-jdk-type="Python SDK" />
</project>

================================================
FILE: .idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/plotneuralnet.iml" filepath="$PROJECT_DIR$/.idea/plotneuralnet.iml" />
    </modules>
  </component>
</project>

================================================
FILE: .idea/plotneuralnet.iml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$" />
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
  <component name="TestRunnerService">
    <option name="projectConfiguration" value="Nosetests" />
    <option name="PROJECT_TEST_RUNNER" value="Nosetests" />
  </component>
</module>

================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="$PROJECT_DIR$" vcs="Git" />
  </component>
</project>

================================================
FILE: .idea/workspace.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="776fe343-0ed9-4619-bd19-7a1b6f20e48a" name="Default" comment="" />
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="ProjectFrameBounds" extendedState="6">
    <option name="x" value="97" />
    <option name="y" value="24" />
    <option name="width" value="888" />
    <option name="height" value="1078" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
      <manualOrder />
      <foldersAlwaysOnTop value="true" />
    </navigator>
    <panes>
      <pane id="ProjectPane">
        <subPane>
          <expand>
            <path>
              <item name="plotneuralnet" type="b2602c69:ProjectViewProjectNode" />
              <item name="plotneuralnet" type="462c0819:PsiDirectoryNode" />
            </path>
          </expand>
          <select />
        </subPane>
      </pane>
      <pane id="Scope" />
      <pane id="Scratches" />
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
  </component>
  <component name="RunDashboard">
    <option name="ruleStates">
      <list>
        <RuleState>
          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
        </RuleState>
        <RuleState>
          <option name="name" value="StatusDashboardGroupingRule" />
        </RuleState>
      </list>
    </option>
  </component>
  <component name="ShelveChangesManager" show_recycled="false">
    <option name="remove_strategy" value="false" />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="776fe343-0ed9-4619-bd19-7a1b6f20e48a" name="Default" comment="" />
      <created>1536764917516</created>
      <option name="number" value="Default" />
      <option name="presentableId" value="Default" />
      <updated>1536764917516</updated>
    </task>
    <servers />
  </component>
  <component name="ToolWindowManager">
    <frame x="97" y="24" width="1855" height="1085" extended-state="6" />
    <layout>
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24985963" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33032694" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
    </layout>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
</project>

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2018 HarisIqbal88

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# PlotNeuralNet
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2526396.svg)](https://doi.org/10.5281/zenodo.2526396)

Latex code for drawing neural networks for reports and presentation. Have a look into examples to see how they are made. Additionally, lets consolidate any improvements that you make and fix any bugs to help more people with this code.

## Examples

Following are some network representations:

<p align="center"><img  src="https://user-images.githubusercontent.com/17570785/50308846-c2231880-049c-11e9-8763-3daa1024de78.png" width="85%" height="85%"></p>
<h6 align="center">FCN-8 (<a href="https://www.overleaf.com/read/kkqntfxnvbsk">view on Overleaf</a>)</h6>


<p align="center"><img  src="https://user-images.githubusercontent.com/17570785/50308873-e2eb6e00-049c-11e9-9587-9da6bdec011b.png" width="85%" height="85%"></p>
<h6 align="center">FCN-32 (<a href="https://www.overleaf.com/read/wsxpmkqvjnbs">view on Overleaf</a>)</h6>


<p align="center"><img  src="https://user-images.githubusercontent.com/17570785/50308911-03b3c380-049d-11e9-92d9-ce15669017ad.png" width="85%" height="85%"></p>
<h6 align="center">Holistically-Nested Edge Detection (<a href="https://www.overleaf.com/read/jxhnkcnwhfxp">view on Overleaf</a>)</h6>

## Getting Started
1. Install the following packages on Ubuntu.
    * Ubuntu 16.04
        ```
        sudo apt-get install texlive-latex-extra
        ```

    * Ubuntu 18.04.2
Base on this [website](https://gist.github.com/rain1024/98dd5e2c6c8c28f9ea9d), please install the following packages.
        ```
        sudo apt-get install texlive-latex-base
        sudo apt-get install texlive-fonts-recommended
        sudo apt-get install texlive-fonts-extra
        sudo apt-get install texlive-latex-extra
        ```

    * Windows
    1. Download and install [MikTeX](https://miktex.org/download).
    2. Download and install bash runner on Windows, recommends [Git bash](https://git-scm.com/download/win) or Cygwin(https://www.cygwin.com/)

2. Execute the example as followed.
    ```
    cd pyexamples/
    bash ../tikzmake.sh test_simple
    ```

## TODO

- [X] Python interface
- [ ] Add easy legend functionality
- [ ] Add more layer shapes like TruncatedPyramid, 2DSheet etc
- [ ] Add examples for RNN and likes.

## Latex usage

See [`examples`](examples) directory for usage.

## Python usage

First, create a new directory and a new Python file:

    $ mkdir my_project
    $ cd my_project
    vim my_arch.py

Add the following code to your new file:

```python
import sys
sys.path.append('../')
from pycore.tikzeng import *

# defined your arch
arch = [
    to_head( '..' ),
    to_cor(),
    to_begin(),
    to_Conv("conv1", 512, 64, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=2 ),
    to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)"),
    to_Conv("conv2", 128, 64, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=2 ),
    to_connection( "pool1", "conv2"),
    to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=28, depth=28, width=1),
    to_SoftMax("soft1", 10 ,"(3,0,0)", "(pool1-east)", caption="SOFT"  ),
    to_connection("pool2", "soft1"),
    to_end()
    ]

def main():
    namefile = str(sys.argv[0]).split('.')[0]
    to_generate(arch, namefile + '.tex' )

if __name__ == '__main__':
    main()
```

Now, run the program as follows:

    bash ../tikzmake.sh my_arch





================================================
FILE: examples/AlexNet/alexnet.tex
================================================
\documentclass[border=8pt, multi, tikz]{standalone} 
\usepackage{import}
\subimport{../layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image 


\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,2;green,5;white,5}
\def\FcReluColor{blue,2;green,5;;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}   


\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width=0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]


\pic[shift={(0,0,0)}] at (0,0,0) 
    {Box={
        name=conv0,
        caption= ,
        xlabel={{3, }},
        zlabel=224,
        fill=\ConvColor,
        height=44.8,
        width=3,
        depth=44.8
        }
    };


\pic[shift={(1,0,0)}] at (conv0-east) 
    {Box={
        name=conv1,
        caption= ,
        xlabel={{96, }},
        zlabel=55,
        fill=\ConvColor,
        height=11.0,
        width=4.8,
        depth=11.0
        }
    };


\draw [connection]  (conv0-east)    -- node {\midarrow} (conv1-west);


\pic[shift={ (0,0,0) }] at (conv1-east) 
    {Box={
        name=pool1,
        caption= ,
        fill=\PoolColor,
        opacity=0.5,
        height=5.4,
        width=1,
        depth=5.4
        }
    };


\pic[shift={(1,0,0)}] at (pool1-east) 
    {Box={
        name=conv2,
        caption= ,
        xlabel={{256, }},
        zlabel=27,
        fill=\ConvColor,
        height=5.4,
        width=12.8,
        depth=5.4
        }
    };


\draw [connection]  (pool1-east)    -- node {\midarrow} (conv2-west);


\pic[shift={ (0,0,0) }] at (conv2-east) 
    {Box={
        name=pool2,
        caption= ,
        fill=\PoolColor,
        opacity=0.5,
        height=2.6,
        width=1,
        depth=2.6
        }
    };


\pic[shift={(1,0,0)}] at (pool2-east) 
    {Box={
        name=conv3,
        caption= ,
        xlabel={{384, }},
        zlabel=13,
        fill=\ConvColor,
        height=2.6,
        width=19.2,
        depth=2.6
        }
    };


\draw [connection]  (pool2-east)    -- node {\midarrow} (conv3-west);


\pic[shift={(1,0,0)}] at (conv3-east) 
    {Box={
        name=conv4,
        caption= ,
        xlabel={{384, }},
        zlabel=13,
        fill=\ConvColor,
        height=2.6,
        width=19.2,
        depth=2.6
        }
    };


\draw [connection]  (conv3-east)    -- node {\midarrow} (conv4-west);


\pic[shift={(1,0,0)}] at (conv4-east) 
    {Box={
        name=conv5,
        caption= ,
        xlabel={{256, }},
        zlabel=13,
        fill=\ConvColor,
        height=2.6,
        width=12.8,
        depth=2.6
        }
    };


\draw [connection]  (conv4-east)    -- node {\midarrow} (conv5-west);


\pic[shift={ (0,0,0) }] at (conv5-east) 
    {Box={
        name=pool3,
        caption= ,
        fill=\PoolColor,
        opacity=0.5,
        height=1.2,
        width=1,
        depth=1.2
        }
    };


\pic[shift={(1,0,0)}] at (pool3-east) 
    {Box={
        name=Fc1,
        caption= ,
        xlabel={{1, }},
        zlabel=4096,
        fill=\FcColor,
        height=1,
        width=1,
        depth=40.96
        }
    };


\draw [connection]  (pool3-east)    -- node {\midarrow} (Fc1-west);


\pic[shift={(2,0,0)}] at (Fc1-east) 
    {Box={
        name=Fc2,
        caption= ,
        xlabel={{1, }},
        zlabel=4096,
        fill=\FcColor,
        height=1,
        width=1,
        depth=40.96
        }
    };


\draw [connection]  (Fc1-east)    -- node {\midarrow} (Fc2-west);


\pic[shift={(3,0,0)}] at (Fc2-east) 
    {Box={
        name=soft1,
        caption=SOFT,
        xlabel={{" ","dummy"}},
        zlabel=1000,
        fill=\SoftmaxColor,
        opacity=0.8,
        height=3,
        width=1.5,
        depth=25
        }
    };


\draw [connection]  (Fc2-east)    -- node {\midarrow} (soft1-west);


\end{tikzpicture}
\end{document}


================================================
FILE: examples/HED/HED.tex
================================================
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\DcnvColor{rgb:blue,5;green,2.5;white,5}
\def\SoftmaxColor{rgb:magenta,5;black,7}
\def\SumColor{rgb:blue,5;green,15}
\def\poolsep{1}


\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.6]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Layer Blocks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2,%pool1
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,%
        xlabel={{"64","64"}},zlabel=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
\pic[shift={(\poolsep,0,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.5,height=30,width=1,depth=30}};
% conv2_1,conv2_2,pool2
\pic[shift={(1,0,0)}] at (p1-east) {RightBandedBox={name=cr2,%
        xlabel={{"64","64"}},zlabel=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=30,width={3,3},depth=30}};
\pic[shift={(\poolsep,0,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.5,height=23,width=1,depth=23}};
% conv3_1,conv3_2,pool3
\pic[shift={(1,0,0)}] at (p2-east) {RightBandedBox={name=cr3,%
        xlabel={{"256","256","256"}},zlabel=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=23,width={4,4,4},depth=23}};
\pic[shift={(\poolsep,0,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.5,height=14,width=1,depth=14}};
% conv4_1,conv4_2,conv4_3,pool4
\pic[shift={(1,0,0)}] at (p3-east) {RightBandedBox={name=cr4,%
        xlabel={{"512","512","512"}},zlabel=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=14,width={7,7,7},depth=14}};
\pic[shift={(\poolsep,0,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.5,height=8,width=1,depth=8}};
% conv5_1,conv5_2,conv5_3,pool5
\pic[shift={(1,0,0)}] at (p4-east) {RightBandedBox={name=cr5,%
        xlabel={{"512","512","512"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=8,width={7,7,7},depth=8}};
%% fc8 -> cr8 (score32)
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=score16,%
        xlabel={{"K","dummy"}},fill=\ConvColor,%
        height=8,width=2,depth=8,zlabel=I/16}};

%% Upsampling Deconv Layer
%% Dcnv16    
\pic[shift={(2.5,0,0)}] at (score16-east) {Box={name=d16,%
        xlabel={{"","dummy"}},fill=\DcnvColor,opacity=0.7,height=40,width=0.5,depth=40}};
%% Dcnv8    
\pic[shift={(.25,0,0)}] at (d16-east) {Box={name=d8,%
        xlabel={{"","dummy"}},fill=\DcnvColor,opacity=0.7,height=40,width=0.5,depth=40}};
%% Dcnv4    
\pic[shift={(.25,0,0)}] at (d8-east) {Box={name=d4,%
        xlabel={{"","dummy"}},fill=\DcnvColor,opacity=0.7,height=40,width=0.5,depth=40}};
%% Dcnv2    
\pic[shift={(.25,0,0)}] at (d4-east) {Box={name=d2,%
        xlabel={{"","dummy"}},fill=,opacity=0.01,height=40,width=0.5,depth=40}};

%% Dcnv envelope    
\pic[shift={(-0.2,0,0)}] at (d16-west) {Box={name=env,caption=concatenation of deconvolved feature maps,%
        xlabel={{"","dummy"}},fill=,opacity=0.2,height=42,width={8},depth=42}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\skipshift{6.5}
%%Joining with previous streams (fcn-16)
%% score16
\pic[shift={(0,0,3+\skipshift)}] at (cr5-anchor) {Box={name=score8,%
        xlabel={{"K","dummy"}},fill=\ConvColor,height=14,width=2,depth=14,zlabel=I/8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Joining with previous streams (fcn-8)
%% score8
\pic[shift={(0,0,8+\skipshift)}] at (cr4-east) {Box={name=score4,%
        xlabel={{"K","dummy"}},fill=\ConvColor,height=23,width=2,depth=23,zlabel=I/4}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Joining with previous streams (fcn-4)
%% score4
\pic[shift={(1,0,13+\skipshift)}] at (cr3-east) {Box={name=score2,%
        xlabel={{"K","dummy"}},fill=\ConvColor,height=30,width=2,depth=30,zlabel=I/2}}; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Joining with previous streams (fcn-2)
%% score2
\pic[shift={(0.3,0,22+\skipshift)}] at (p2-east) {Box={name=score,%
        xlabel={{"K","dummy"}},fill=\ConvColor,height=40,width=2,depth=40,zlabel=I}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Final convolution

\pic[shift={(3,0,0)}] at (d2-east) {Box={name=output,%
        xlabel={{"K","dummy"}},fill=\ConvColor,height=40,width=2,depth=40,zlabel=I}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (cr1-east)    -- node {\midarrow} (p1-west);
\draw [connection]  (p1-east)    -- node {\midarrow} (cr2-west);
\draw [connection]  (cr2-east)    -- node {\midarrow} (p2-west);
\draw [connection]  (p2-east)    -- node {\midarrow} (cr3-west);
\draw [connection]  (cr3-east)    -- node {\midarrow} (p3-west);
\draw [connection]  (p3-east)    -- node {\midarrow} (cr4-west);
\draw [connection]  (cr4-east)    -- node {\midarrow} (p4-west);
\draw [connection]  (p4-east)    -- node {\midarrow} (cr5-west);
\draw [connection]  (score16-east)    -- node {\midarrow} (d16-west);
%
\path (cr4-east) -- (p4-west) coordinate[pos=0.4] (after4) ;
\draw (d16-near)++(0,0,-1+\skipshift) coordinate (d16h);
\draw [connection]  (after4)    -- node {\midarrow} ++(0,0,3+\skipshift) -- node {\midarrow} (score8-west);
\draw [connection]  (score8-east) -- node{\midarrow} (d16h) -- node{\midarrow}(d16-near);
%
\path (cr3-east) -- (p3-west) coordinate[pos=0.4] (after3) ;
\draw (d8-near)++(0,0,4+\skipshift) coordinate (d8h);
\draw [connection]  (after3)    -- node {\midarrow} ++(0,0,8+\skipshift) -- node {\midarrow} (score4-west);
\draw [connection]  (score4-east) -- node{\midarrow} (d8h) -- node{\midarrow}(d8-near);
%
\path (cr2-east) -- (p2-west) coordinate[pos=0.4] (after2) ;
\draw (d4-near)++(0,0,9+\skipshift) coordinate (d4h);
\draw [connection]  (after2)    -- node {\midarrow} ++(0,0,13+\skipshift) -- node {\midarrow} (score2-west);
\draw [connection]  (score2-east) -- node{\midarrow} (d4h) -- node{\midarrow}(d4-near);
%
\path (cr1-east) -- (p1-west) coordinate[pos=0.4] (after1) ;
\draw (d2-near)++(0,0,18+\skipshift) coordinate (d2h);
\draw [connection]  (after1)    -- node {\midarrow} ++(0,0,22+\skipshift) -- node {\midarrow} (score-west);
\draw [connection]  (score-east) -- node{\midarrow} (d2h) -- node{\midarrow}(d2-near);

\draw [connection]  (d2-east)    -- node {\midarrow} (output-west);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikzpicture}
\end{document}\grid


================================================
FILE: examples/LeNet/lenet.tex
================================================
\documentclass[border=8pt, multi, tikz]{standalone} 
\usepackage{import}
\subimport{../layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image 


\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}   


\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width=0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]


\pic[shift={(0,0,0)}] at (0,0,0) 
    {Box={
        name=conv0,
        caption= ,
        xlabel={{1, }},
        zlabel=32,
        fill=\ConvColor,
        height=32,
        width=1,
        depth=32
        }
    };


\pic[shift={(1,0,0)}] at (conv0-east) 
    {Box={
        name=conv1,
        caption= ,
        xlabel={{6, }},
        zlabel=28,
        fill=\ConvColor,
        height=28,
        width=6,
        depth=28
        }
    };


\draw [connection]  (conv0-east)    -- node {\midarrow} (conv1-west);


\pic[shift={ (0,0,0) }] at (conv1-east) 
    {Box={
        name=pool1,
        caption= ,
        fill=\PoolColor,
        opacity=0.5,
        height=14,
        width=6,
        depth=14
        }
    };


\pic[shift={(1,0,0)}] at (pool1-east) 
    {Box={
        name=conv2,
        caption= ,
        xlabel={{16, }},
        zlabel=10,
        fill=\ConvColor,
        height=10,
        width=16,
        depth=10
        }
    };


\draw [connection]  (pool1-east)    -- node {\midarrow} (conv2-west);


\pic[shift={ (0,0,0) }] at (conv2-east) 
    {Box={
        name=pool2,
        caption= ,
        fill=\PoolColor,
        opacity=0.5,
        height=5,
        width=16,
        depth=5
        }
    };


\pic[shift={(1,0,0)}] at (pool2-east) 
    {Box={
        name=conv3,
        caption= ,
        xlabel={{1, }},
        zlabel=120,
        fill=\ConvColor,
        height=1,
        width=1,
        depth=120
        }
    };


\draw [connection]  (pool2-east)    -- node {\midarrow} (conv3-west);


\pic[shift={(2,0,0)}] at (conv3-east) 
    {Box={
        name=conv4,
        caption= ,
        xlabel={{1, }},
        zlabel=84,
        fill=\ConvColor,
        height=1,
        width=1,
        depth=84
        }
    };


\draw [connection]  (conv3-east)    -- node {\midarrow} (conv4-west);


\pic[shift={(3,0,0)}] at (conv4-east) 
    {Box={
        name=soft1,
        caption=SOFT,
        xlabel={{" ","dummy"}},
        zlabel=10,
        fill=\SoftmaxColor,
        opacity=0.8,
        height=3,
        width=1.5,
        depth=25
        }
    };


\draw [connection]  (conv4-east)    -- node {\midarrow} (soft1-west);


\end{tikzpicture}
\end{document}


================================================
FILE: examples/LeNet/lenet.txt
================================================
input(32, 32, 1)
conv(28, 28, 6)
pool(14, 14, 6)
conv(10, 10, 16)
pool(5, 5, 16)
conv(1,1,120)
fullyconn(1,1,84)
softmax(1,1,10)

================================================
FILE: examples/SoftmaxLoss/SoftmaxLoss.tex
================================================
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\newcommand{\up}{0.25}
\newcommand{\down}{0.25}
\newcommand{\arrowlength}{4}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw previous connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (-\arrowlength,\up,0) 
node[anchor=south west,scale=2.1]{$p(x^{(t)})$}   
-- node {\midarrow} (0,\up,0);  
\draw [connection]  (0,-\down,0)  -- node {\midarrow} ++(-\arrowlength.0,0)
node[anchor=north west,inner sep = 10, xshift=-25,scale=2.3]
{
    $\frac{\partial L}{\partial E_\mathcal{S}}\frac{\partial E_\mathcal{S}}{\partial p}$
};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Layer Blocks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(0,0,0)}] at (0,0,0) {Box={name=crp1,caption=SoftmaxLoss: $E_\mathcal{S}$ ,%
        fill={rgb:blue,1.5;red,3.5;green,3.5;white,5},opacity=0.5,height=20,width=7,depth=20}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw next connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (crp1-east)++(0,\up,0) -- node {\midarrow} ++(\arrowlength.0,0) 
node [anchor=south east,scale=2.1]{$E_\mathcal{S} [p;\theta]$};

\draw [connection]  (crp1-east)++(\arrowlength,-\down,0)  
node[anchor=north east,inner sep = 10, xshift=25,scale=2.3]
{
    $\frac{\partial L}{\partial E_\mathcal{S}} = \lambda_\mathcal{S}$
}   
-- node {\midarrow} ++(-\arrowlength,0,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   		

\end{tikzpicture}
\end{document}


================================================
FILE: examples/Unet/Unet.tex
================================================
\documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}


\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Encoder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,%
        xlabel={{"64","64"}},zlabel=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
%pool1
\pic[shift={(0,0,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.5,height=32,width=1,depth=32}};
%%%%%%%%%%
% conv2_1,conv2_2
\pic[shift={(1,0,0)}] at (p1-east) {RightBandedBox={name=cr2,%
        xlabel={{"128","128"}},zlabel=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width={3.5,3.5},depth=32}};
%pool2
\pic[shift={(0,0,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.5,height=25,width=1,depth=25}};
%%%%%%%%%%
% conv3_1,conv3_2
\pic[shift={(0.75,0,0)}] at (p2-east) {RightBandedBox={name=cr3,%
        xlabel={{"256","256"}},zlabel=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width={4.5,4.5},depth=25}};
%pool3
\pic[shift={(0,0,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.5,height=16,width=1,depth=16}};
%%%%%%%%%%
% conv4_1,conv4_2,conv4_3
\pic[shift={(0.5,0,0)}] at (p3-east) {RightBandedBox={name=cr4,%
        xlabel={{"512","512"}},zlabel=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width={6,6},depth=16}};
%pool4
\pic[shift={(0,0,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.5,height=8,width=1,depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bottleneck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% conv5_1,conv5_2,conv5_3
\pic[shift={(0.75,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=Bottleneck Conv,%
        xlabel={{"1024","1024"}},zlabel=I/16,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=8,width={8,8},depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Decoder 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% unpool4, 
\pic[shift={(1.2,0,0)}] at (cr5-east) {Box={name=up4,%
        fill=\UnpoolColor,opacity=0.6,height=16,width=1,depth=16}};
\pic[shift={(0,0,0)}] at (up4-east) {RightBandedBox={name=ucr4,%
        xlabel={{"512","dummy"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width=6,depth=16}};
\pic[shift={(0,0,0)}] at (ucr4-east) {RightBandedBox={name=cat4,%
        xlabel={{"512",""}},fill={rgb:white,1;black,3},bandfill={rgb:white,1;black,2},opacity=0.2,height=16,width=6,depth=16}};    
\pic[shift={(0,0,0)}] at (cat4-east) {RightBandedBox={name=ucr4a,%
        xlabel={{"512","512"}},zlabel=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width={6,6},depth=16}};
%%%%%%%%%%
%% unpool3, 
\pic[shift={(1.5,0,0)}] at (ucr4a-east) {Box={name=up3,%
        fill=\UnpoolColor,opacity=0.6,height=25,width=1,depth=25}};
\pic[shift={(0,0,0)}] at (up3-east) {RightBandedBox={name=ucr3,%
        xlabel={{"256","dummy"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width=4.5,depth=25}};
\pic[shift={(0,0,0)}] at (ucr3-east) {RightBandedBox={name=cat3,%
        xlabel={{"256",""}},fill={rgb:white,1;black,3},bandfill={rgb:white,1;black,2},opacity=0.2,height=25,width=4.5,depth=25}};
\pic[shift={(0,0,0)}] at (cat3-east) {RightBandedBox={name=ucr3a,%
        xlabel={{"256","256"}},zlabel=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width={4.5,4.5},depth=25}};
%%%%%%%%%%
%% unpool2, 
\pic[shift={(1,0,0)}] at (ucr3a-east) {Box={name=up2,%
        fill=\UnpoolColor,opacity=0.6,height=32,width=1,depth=32}};
\pic[shift={(0,0,0)}] at (up2-east) {RightBandedBox={name=ucr2,%
        xlabel={{"128","dummy"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width=3.5,depth=32}};
\pic[shift={(0,0,0)}] at (ucr2-east) {RightBandedBox={name=cat2,%
        xlabel={{"128",""}},fill={rgb:white,1;black,3},bandfill={rgb:white,1;black,2},opacity=0.2,height=32,width=3.5,depth=32}};    
\pic[shift={(0,0,0)}] at (cat2-east) {RightBandedBox={name=ucr2a,%
        xlabel={{"128","128"}},zlabel=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width={3.5,3.5},depth=32}};
%%%%%%%%%%
%% unpool1, 
\pic[shift={(1.5,0,0)}] at (ucr2a-east) {Box={name=up1,%
        fill=\UnpoolColor,opacity=0.6,height=40,width=1,depth=40}};
\pic[shift={(0,0,0)}] at (up1-east) {RightBandedBox={name=ucr1,%
        xlabel={{"64","dummy"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width=2.5,depth=40}};
\pic[shift={(0,0,0)}] at (ucr1-east) {RightBandedBox={name=cat1,%
        xlabel={{"64",""}},fill={rgb:white,1;black,3},bandfill={rgb:white,1;black,2},opacity=0.2,height=40,width=2.5,depth=40}};  
\pic[shift={(0,0,0)}] at (cat1-east) {RightBandedBox={name=ucr1a,%
        xlabel={{"64","64"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2.5,2.5},depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Classifier 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(0.75,0,0)}] at (ucr1a-east) {Box={name=out,caption=Softmax,%
        zlabel=I,fill=\SoftmaxColor,height=40,width=1,depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (p1-east)    -- node {\midarrow} (cr2-west);
\draw [connection]  (p2-east)    -- node {\midarrow} (cr3-west);
\draw [connection]  (p3-east)    -- node {\midarrow} (cr4-west);
\draw [connection]  (p4-east)    -- node {\midarrow} (cr5-west);
\draw [connection]  (cr5-east)   -- node {\midarrow} (up4-west);
\draw [connection]  (ucr4a-east) -- node {\midarrow} (up3-west);
\draw [connection]  (ucr3a-east) -- node {\midarrow} (up2-west);
\draw [connection]  (ucr2a-east) -- node {\midarrow} (up1-west);
\draw [connection]  (ucr1a-east) -- node {\midarrow} (out-west);
%\draw [connection]  (out-east)   -- node {\midarrow} ++(2,0,0);

\path (cr4-southeast) -- (cr4-northeast) coordinate[pos=1.25] (cr4-top) ;
\path (cr3-southeast) -- (cr3-northeast) coordinate[pos=1.25] (cr3-top) ;
\path (cr2-southeast) -- (cr2-northeast) coordinate[pos=1.25] (cr2-top) ;
\path (cr1-southeast) -- (cr1-northeast) coordinate[pos=1.25] (cr1-top) ;

\path (cat4-south)  -- (cat4-north)  coordinate[pos=1.25] (cat4-top) ;
\path (cat3-south)  -- (cat3-north)  coordinate[pos=1.25] (cat3-top) ;
\path (cat2-south)  -- (cat2-north)  coordinate[pos=1.25] (cat2-top)  ;
\path (cat1-south)  -- (cat1-north)  coordinate[pos=1.25] (cat1-top)  ;
%
\draw [copyconnection]  (cr4-northeast)  
-- node {\copymidarrow}(cr4-top)
-- node {\copymidarrow}(cat4-top)
-- node {\copymidarrow} (cat4-north);
%
\draw [copyconnection]  (cr3-northeast)  
-- node {\copymidarrow}(cr3-top)
-- node {\copymidarrow}(cat3-top)
-- node {\copymidarrow} (cat3-north);
%
\draw [copyconnection]  (cr2-northeast)  
-- node {\copymidarrow}(cr2-top)
-- node {\copymidarrow}(cat2-top)
-- node {\copymidarrow} (cat2-north);
%
\draw [copyconnection]  (cr1-northeast)  
-- node {\copymidarrow}(cr1-top)
-- node {\copymidarrow}(cat1-top)
-- node {\copymidarrow} (cat1-north);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}


================================================
FILE: examples/Unet_Ushape/Unet_ushape.tex
================================================
\documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\ConcatColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}


\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Encoder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,%
        xlabel={{"64","64"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
%pool1
\pic[shift={(1.2,-10,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.6,height=32,width=1,depth=32}};
%%%%%%%%%%
% conv2_1,conv2_2
\pic[shift={(0,0,0)}] at (p1-east) {RightBandedBox={name=cr2,%
        xlabel={{"128","128"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width={3.5,3.5},depth=32}};
%pool2
\pic[shift={(1.2,-8.5,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.6,height=25,width=1,depth=25}};
%%%%%%%%%%
% conv3_1,conv3_2
\pic[shift={(0,0,0)}] at (p2-east) {RightBandedBox={name=cr3,%
        xlabel={{"256","256"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width={4.5,4.5},depth=25}};
%pool3
\pic[shift={(1.2,-6.5,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.6,height=16,width=1,depth=16}};
%%%%%%%%%%
% conv4_1,conv4_2,conv4_3
\pic[shift={(0,0,0)}] at (p3-east) {RightBandedBox={name=cr4,%
        xlabel={{"512","512"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width={6,6},depth=16}};
%pool4
\pic[shift={(1.2,-3,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.6,height=8,width=1,depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bottleneck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% conv5_1,conv5_2,conv5_3
\pic[shift={(0,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=I/16,%
        xlabel={{"1024","1024"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=8,width={8,8},depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Decoder 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% unpool4, 
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=up4,%
        fill=\UnpoolColor,opacity=0.6,height=16,width=1,depth=16}};
\pic[shift={(0,0,0)}] at (up4-east) {RightBandedBox={name=ucr4,%
        xlabel={{"512","dummy"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width=6,depth=16}};
\pic[shift={(0,3,0)}] at (ucr4-anchor) {Ball={name=cat4,fill=\ConcatColor,radius=2.5,logo=$||$}};    
\pic[shift={(1.4,0,0)}] at (cat4-east) {RightBandedBox={name=ucr4a,%
        xlabel={{"512","512"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=16,width={6,6},depth=16}};
%%%%%%%%%%
%% unpool3, 
\pic[shift={(0,0,0)}] at (ucr4a-east) {Box={name=up3,%
        fill=\UnpoolColor,opacity=0.6,height=25,width=1,depth=25}};
\pic[shift={(0,0,0)}] at (up3-east) {RightBandedBox={name=ucr3,%
        xlabel={{"256","dummy"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width=4.5,depth=25}};
\pic[shift={(0,6.5,0)}] at (ucr3-anchor) {Ball={name=cat3,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(1.5,0,0)}] at (cat3-east) {RightBandedBox={name=ucr3a,%
        xlabel={{"256","256"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=25,width={4.5,4.5},depth=25}};
%%%%%%%%%%
%% unpool2, 
\pic[shift={(0,0,0)}] at (ucr3a-east) {Box={name=up2,%
        fill=\UnpoolColor,opacity=0.6,height=32,width=1,depth=32}};
\pic[shift={(0,0,0)}] at (up2-east) {RightBandedBox={name=ucr2,%
        xlabel={{"128","dummy"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width=3.5,depth=32}};
\pic[shift={(0,8.5,0)}] at (ucr2-anchor) {Ball={name=cat2,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(1.8,0,0)}] at (cat2-east) {RightBandedBox={name=ucr2a,%
        xlabel={{"128","128"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=32,width={3.5,3.5},depth=32}};
%%%%%%%%%%
%% unpool1, 
\pic[shift={(0,0,0)}] at (ucr2a-east) {Box={name=up1,%
        fill=\UnpoolColor,opacity=0.6,height=40,width=1,depth=40}};
\pic[shift={(0,0,0)}] at (up1-east) {RightBandedBox={name=ucr1,%
        xlabel={{"64","dummy"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width=2.5,depth=40}};
\pic[shift={(0,10,0)}] at (ucr1-anchor) {Ball={name=cat1,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(2,0,0)}] at (cat1-east) {RightBandedBox={name=ucr1a,%
        xlabel={{"64","64"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2.5,2.5},depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Classifier 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(2,0,0)}] at (ucr1a-east) {Box={name=out,caption=Softmax,%
        zlabel=I,fill=\SoftmaxColor,height=40,width=1,depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\path (cr1-east) -- (p1-west|-cr1-west) coordinate[pos=0.5] (crp1-mid) ;
\path (cr2-east) -- (p2-west|-cr2-west) coordinate[pos=0.5] (crp2-mid) ;
\path (cr3-east) -- (p3-west|-cr3-west) coordinate[pos=0.5] (crp3-mid) ;
\path (cr4-east) -- (p4-west|-cr4-west) coordinate[pos=0.5] (crp4-mid) ;

\draw[connection](cr1-east)--node{\midarrow}(crp1-mid)--node{\midarrow}(p1-west-|crp1-mid)--node{\midarrow}(p1-west);
\draw[connection](cr2-east)--node{\midarrow}(crp2-mid)--node{\midarrow}(p2-west-|crp2-mid)--node{\midarrow}(p2-west);
\draw[connection](cr3-east)--node{\midarrow}(crp3-mid)--node{\midarrow}(p3-west-|crp3-mid)--node{\midarrow}(p3-west);
\draw[connection](cr4-east)--node{\midarrow}(crp4-mid)--node{\midarrow}(p4-west-|crp4-mid)--node{\midarrow}(p4-west);

%\draw [connection]  (cr5-east)   -- node {\midarrow} (up4-west);
%\draw [connection]  (ucr4a-east) -- node {\midarrow} (up3-west);
%\draw [connection]  (ucr3a-east) -- node {\midarrow} (up2-west);
%\draw [connection]  (ucr2a-east) -- node {\midarrow} (up1-west);
\draw [connection]  (ucr1a-east) -- node {\midarrow} (out-west);
%\draw [connection]  (out-east)   -- node {\midarrow} ++(2,0,0);

\draw [copyconnection]  (cr4-east)  -- node {\copymidarrow} (cat4-west);
\draw [copyconnection]  (cr3-east)  -- node {\copymidarrow} (cat3-west);
\draw [copyconnection]  (cr2-east)  -- node {\copymidarrow} (cat2-west);
\draw [copyconnection]  (cr1-east)  -- node {\copymidarrow} (cat1-west);

\draw [copyconnection]  (cat4-east)  -- node {\copymidarrow} (ucr4a-west);
\draw [copyconnection]  (cat3-east)  -- node {\copymidarrow} (ucr3a-west);
\draw [copyconnection]  (cat2-east)  -- node {\copymidarrow} (ucr2a-west);
\draw [copyconnection]  (cat1-east)  -- node {\copymidarrow} (ucr1a-west);

\draw [copyconnection]  (ucr4-north)  -- node {\copymidarrow} (cat4-south);
\draw [copyconnection]  (ucr3-north)  -- node {\copymidarrow} (cat3-south);
\draw [copyconnection]  (ucr2-north)  -- node {\copymidarrow} (cat2-south);
\draw [copyconnection]  (ucr1-north)  -- node {\copymidarrow} (cat1-south);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}


================================================
FILE: examples/VGG16/vgg16.tex
================================================
\documentclass[border=15pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Layer Blocks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,caption=conv1,%
        xlabel={{"64","64"}},ylabel=224,zlabel=224,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
%pool1
\pic[shift={(0,0,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.5,height=35,width=1,depth=35}};
%%%%%%%%%%
% conv2_1,conv2_2
\pic[shift={(2,0,0)}] at (p1-east) {RightBandedBox={name=cr2,caption=conv2,%
        xlabel={{"128","128"}},zlabel=112,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=35,width={3,3},depth=35}};
%pool2
\pic[shift={(0,0,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.5,height=30,width=1,depth=30}};
%%%%%%%%%%
% conv3_1,conv3_2
\pic[shift={(2,0,0)}] at (p2-east) {RightBandedBox={name=cr3,caption=conv3,%
        xlabel={{"256","256","256"}},zlabel=56,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=30,width={4,4,4},depth=30}};
%pool3
\pic[shift={(0,0,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.5,height=23,width=1,depth=23}};
%%%%%%%%%%
% conv4_1,conv4_2,conv4_3
\pic[shift={(1.8,0,0)}] at (p3-east) {RightBandedBox={name=cr4,caption=conv4,%
        xlabel={{"512","512","512"}},zlabel=28,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=23,width={7,7,7},depth=23}};
%pool4
\pic[shift={(0,0,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.5,height=15,width=1,depth=15}};
%%%%%%%%%%
% conv5_1,conv5_2,conv5_3
\pic[shift={(1.5,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=conv5,%
        xlabel={{"512","512","512"}},zlabel=14,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=15,width={7,7,7},depth=15}};
%pool5
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=p5,%
        fill=\PoolColor,opacity=0.5,height=10,width=1,depth=10}};
%%%%%%%%%%
% fc6
\pic[shift={(3,0,0)}] at (p5-east) {RightBandedBox={name=fc6,caption=fc6,%
        xlabel={{"1",""}},zlabel=4096,fill=\FcColor,bandfill=\FcReluColor,%
        height=3,width=3,depth=100}};
%%%%%%%%%%
% fc7
\pic[shift={(2,0,0)}] at (fc6-east) {RightBandedBox={name=fc7,caption=fc7,%
        xlabel={{"1","dummy"}},zlabel=4096,fill=\FcColor,bandfill=\FcReluColor,%
        height=3,width=3,depth=100}};
%%%%%%%%%%
% fc8
\pic[shift={(1.5,0,0)}] at (fc7-east) {RightBandedBox={name=fc8,caption=fc8+softmax,%
        xlabel={{"1","dummy"}},fill=\FcColor,bandfill=\FcReluColor,%
        height=3,width=3,depth=25}};

%%%%%%%%%%
% softmax
\pic[shift={(0,0,0)}] at (fc8-east) {Box={name=softmax,%
        xlabel={{"","dummy"}},zlabel=K,opacity=0.8,fill=\SoftmaxColor,%
        height=3,width=1.5,depth=25}};
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Arrow Connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (p1-east)        -- node {\midarrow} (cr2-west);
\draw [connection]  (p2-east)        -- node {\midarrow} (cr3-west);
\draw [connection]  (p3-east)        -- node {\midarrow} (cr4-west);
\draw [connection]  (p4-east)        -- node {\midarrow} (cr5-west);
\draw [connection]  (p5-east)        -- node {\midarrow} (fc6-west);
\draw [connection]  (fc6-east)       -- node {\midarrow} (fc7-west);
\draw [connection]  (fc7-east)       -- node {\midarrow} (fc8-west);
\draw [connection]  (softmax-east)   -- node {\midarrow} ++(1.5,0,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Dotted Edges 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[densely dashed]
    (fc6-west)++(0, 1.5*.2, 1.5*.2) coordinate(a) -- (p5-nearnortheast)
    (fc6-west)++(0,-1.5*.2, 1.5*.2) coordinate(b) -- (p5-nearsoutheast)
    (fc6-west)++(0,-1.5*.2,-1.5*.2) coordinate(c) -- (p5-farsoutheast)
    (fc6-west)++(0, 1.5*.2,-1.5*.2) coordinate(d) -- (p5-farnortheast)
    
    (a)--(b)--(c)--(d)
    ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}


================================================
FILE: examples/fcn32s/fcn32.tex
================================================
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\DcnvColor{rgb:blue,5;green,2.5;white,5}
\def\SoftmaxColor{rgb:magenta,5;black,7}

\begin{document}

\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Layer Blocks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,caption=conv1,%
        xlabel={{"64","64"}},zlabel=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
%pool1
\pic[shift={(0,0,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.5,height=35,width=1,depth=35}};
%%%%%%%%%%
% conv2_1,conv2_2
\pic[shift={(2,0,0)}] at (p1-east) {RightBandedBox={name=cr2,caption=conv2,%
        xlabel={{"64","64"}},zlabel=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=35,width={3,3},depth=35}};
%pool2
\pic[shift={(0,0,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.5,height=30,width=1,depth=30}};
%%%%%%%%%%
% conv3_1,conv3_2
\pic[shift={(2,0,0)}] at (p2-east) {RightBandedBox={name=cr3,caption=conv3,%
        xlabel={{"256","256","256"}},zlabel=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=30,width={4,4,4},depth=30}};
%pool3
\pic[shift={(0,0,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.5,height=23,width=1,depth=23}};
%%%%%%%%%%
% conv4_1,conv4_2,conv4_3
\pic[shift={(1.8,0,0)}] at (p3-east) {RightBandedBox={name=cr4,caption=conv4,%
        xlabel={{"512","512","512"}},zlabel=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=23,width={7,7,7},depth=23}};
%pool4
\pic[shift={(0,0,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.5,height=15,width=1,depth=15}};
%%%%%%%%%%
% conv5_1,conv5_2,conv5_3
\pic[shift={(1.5,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=conv5,%
        xlabel={{"512","512","512"}},zlabel=I/16,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=15,width={7,7,7},depth=15}};
%pool5
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=p5,%
        fill=\PoolColor,opacity=0.5,height=10,width=1,depth=10}};
%%%%%%%%%%     
%% fc6, fc7 -> cr6, cr7
\pic[shift={(1,0,0)}] at (p5-east) {RightBandedBox={name=cr6_7,caption=fc to conv,%
        xlabel={{"4096","4096"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=10,width={10,10},depth=10}};
%%%%%%%%%%   
%% fc8 -> cr8    

\pic[shift={(1,0,0)}] at (cr6_7-east) {Box={name=c8,caption=fc8 to conv,%
        xlabel={{"K","dummy"}},fill=\ConvColor,%
        height=10,width=2,depth=10,zlabel=I/32}};
%%%%%%%%%%   
%% Dcnv32    
\pic[shift={(2.5,0,0)}] at (c8-east) {Box={name=d32,caption=Deconv,%
        xlabel={{"K","dummy"}},fill=\DcnvColor,%
        height=40,width=2,depth=40}}; 
%%%%%%%%%%   
%% softmax    
\pic[shift={(1,0,0)}] at (d32-east) {Box={name=softmax,caption=softmax,%
        xlabel={{"K","dummy"}},fill=\SoftmaxColor,%
        height=40,width=2,depth=40,zlabel=I}};  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (p1-east)    -- node {\midarrow} (cr2-west);
\draw [connection]  (p2-east)    -- node {\midarrow} (cr3-west);
\draw [connection]  (p3-east)    -- node {\midarrow} (cr4-west);
\draw [connection]  (p4-east)    -- node {\midarrow} (cr5-west);
\draw [connection]  (p5-east)    -- node {\midarrow} (cr6_7-west);
\draw [connection]  (cr6_7-east) -- node {\midarrow} (c8-west);
\draw [connection]  (c8-east)    -- node {\midarrow} (d32-west);
\draw [connection]  (d32-east)   -- node {\midarrow} (softmax-west);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Dotted Edges 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[densely dashed]
(c8-nearnortheast) -- (d32-nearnorthwest)
(c8-nearsoutheast) -- (d32-nearsouthwest)
(c8-farsoutheast)  -- (d32-farsouthwest)
(c8-farnortheast)  -- (d32-farnorthwest)
;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}\grid


================================================
FILE: examples/fcn8s/fcn8.tex
================================================
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image 

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\DcnvColor{rgb:blue,5;green,2.5;white,5}
\def\SoftmaxColor{rgb:magenta,5;black,7}
\def\SumColor{rgb:blue,5;green,15}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Layer Blocks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node[canvas is zy plane at x=0] (temp) at (-3,0,0) {\includegraphics[width=8cm,height=8cm]{cats.jpg}};
% conv1_1,conv1_2,%pool1
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,caption=conv1,%
        xlabel={{"64","64"}},zlabel=I,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=40,width={2,2},depth=40}};
\pic[shift={(0,0,0)}] at (cr1-east) {Box={name=p1,%
        fill=\PoolColor,opacity=0.5,height=35,width=1,depth=35}};
% conv2_1,conv2_2,pool2
\pic[shift={(2,0,0)}] at (p1-east) {RightBandedBox={name=cr2,caption=conv2,%
        xlabel={{"64","64"}},zlabel=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=35,width={3,3},depth=35}};
\pic[shift={(0,0,0)}] at (cr2-east) {Box={name=p2,%
        fill=\PoolColor,opacity=0.5,height=30,width=1,depth=30}};
% conv3_1,conv3_2,pool3
\pic[shift={(2,0,0)}] at (p2-east) {RightBandedBox={name=cr3,caption=conv3,%
        xlabel={{"256","256","256"}},zlabel=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=30,width={4,4,4},depth=30}};
\pic[shift={(0,0,0)}] at (cr3-east) {Box={name=p3,%
        fill=\PoolColor,opacity=0.5,height=23,width=1,depth=23}};
% conv4_1,conv4_2,conv4_3,pool4
\pic[shift={(1.8,0,0)}] at (p3-east) {RightBandedBox={name=cr4,caption=conv4,%
        xlabel={{"512","512","512"}},zlabel=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=23,width={7,7,7},depth=23}};
\pic[shift={(0,0,0)}] at (cr4-east) {Box={name=p4,%
        fill=\PoolColor,opacity=0.5,height=15,width=1,depth=15}};
% conv5_1,conv5_2,conv5_3,pool5
\pic[shift={(1.5,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=conv5,%
        xlabel={{"512","512","512"}},zlabel=I/16,fill=\ConvColor,bandfill=\ConvReluColor,%
        height=15,width={7,7,7},depth=15}};
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=p5,%
        fill=\PoolColor,opacity=0.5,height=10,width=1,depth=10}};    
%% fc6, fc7 -> cr6, cr7
\pic[shift={(1,0,0)}] at (p5-east) {RightBandedBox={name=cr6_7,caption=fc to conv,%
        xlabel={{"4096","4096"}},fill=\ConvColor,bandfill=\ConvReluColor,%
        height=10,width={10,10},depth=10}};  
%% fc8 -> cr8 (score32)
\pic[shift={(1,0,0)}] at (cr6_7-east) {Box={name=score32,caption=fc8 to conv,%
        xlabel={{"K","dummy"}},fill=\ConvColor,%
        height=10,width=2,depth=10,zlabel=I/32}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Joining with previous streams (fcn-16s)
%% Upsampling Deconv Layer
%% Dcnv32    
\pic[shift={(1.5,0,0)}] at (score32-east) {Box={name=d32,%
        xlabel={{"K","dummy"}},fill=\DcnvColor,%
        height=15,width=2,depth=15,zlabel=I/16}};  
%% score16
\pic[shift={(0,-4,0)}] at (d32-west) {Box={name=score16,%
            xlabel={{"K","dummy"}},fill=\ConvColor,%
            height=15,width=2,depth=15,zlabel=I/16}};
%% Elementwise sum between score16 and up32
\pic[shift={(1.5,0,0)}] at (d32-east) {Ball={name=elt1,%
        fill=\SumColor,opacity=0.6,%
        radius=2.5,logo=$+$}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Joining with previous streams (fcn-8s)
%% Upsampling Deconv Layer
%% Dcnv16    
\pic[shift={(1.5,0,0)}] at (elt1-east) {Box={name=d16,%
        xlabel={{"K","dummy"}},fill=\DcnvColor,%
        height=23,width=2,depth=23,zlabel=I/8}};  
%% score8
\pic[shift={(0,-6,0)}] at (d16-west) {Box={name=score8,%
        xlabel={{"K","dummy"}},fill=\ConvColor,%
        height=23,width=2,depth=23,zlabel=I/8}};
%% Elementwise sum between score16 and up32
\pic[shift={(1.5,0,0)}] at (d16-east) {Ball={name=elt2,%
        fill=\SumColor,opacity=0.6,%
        radius=2.5,logo=$+$}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
%%% Output
%%%%%%%%%%   
%% Dcnv8    
\pic[shift={(2.5,0,0)}] at (elt2-east) {Box={name=d8,%
        xlabel={{"K","dummy"}},fill=\DcnvColor,%
        height=40,width=2,depth=40}}; 
%%%%%%%%%%   
%% softmax    
\pic[shift={(1,0,0)}] at (d8-east) {Box={name=softmax,caption=softmax,%
        xlabel={{"K","dummy"}},fill=\SoftmaxColor,%
        height=40,width=2,depth=40,zlabel=I}}; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw [connection]  (p1-east)    -- node {\midarrow} (cr2-west);
\draw [connection]  (p2-east)    -- node {\midarrow} (cr3-west);
\draw [connection]  (p3-east)    -- node {\midarrow} (cr4-west);
\draw [connection]  (p4-east)    -- node {\midarrow} (cr5-west);
\draw [connection]  (p5-east)    -- node {\midarrow} (cr6_7-west);
\draw [connection]  (cr6_7-east)   -- node {\midarrow} (score32-west);
\draw [connection]  (score32-east) -- node {\midarrow} (d32-west);

\path (p4-east) -- (cr5-west) coordinate[pos=0.25] (between4_5) ;
\draw [connection]  (between4_5)    -- node {\midarrow} (score16-west-|between4_5) -- node {\midarrow} (score16-west);
\draw [connection]  (d32-east) -- node {\midarrow} (elt1-west);
\draw [connection]  (score16-east) -- node {\midarrow} (score16-east -| elt1-south) -- node {\midarrow} (elt1-south);
\draw [connection]  (elt1-east) -- node {\midarrow} (d16-west);

\path (p3-east) -- (cr4-west) coordinate[pos=0.25] (between3_4) ;
\draw [connection]  (between3_4) -- node {\midarrow} (score8-west-|between3_4) -- node {\midarrow} (score8-west);
\draw [connection]  (d16-east) -- node {\midarrow} (elt2-west);
\draw [connection]  (score8-east) -- node {\midarrow} (score8-east -| elt2-south)-- node {\midarrow} (elt2-south);
\draw [connection]  (elt2-east) -- node {\midarrow} (d8-west);
\draw [connection] (d8-east) -- node{\midarrow} (softmax-west);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{tikzpicture}
\end{document}\grid


================================================
FILE: layers/Ball.sty
================================================
\ProvidesPackage{Ball}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This Block can draw small Ball
%Elementwise or reduction operations can be drawn with this
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\tikzset{Ball/.pic={\tikzset{/sphere/.cd,#1}	 	

\pgfmathsetmacro{\r}{\radius*\scale}

\shade[ball color=\fill,opacity=\opacity] (0,0,0) circle (\r);
\draw (0,0,0) circle [radius=\r] node[scale=4*\r] {\logo};

\coordinate (\name-anchor) at ( 0 , 0  , 0) ;
\coordinate (\name-east)   at ( \r, 0  , 0) ;
\coordinate (\name-west)   at (-\r, 0  , 0) ;
\coordinate (\name-north)  at ( 0 , \r , 0) ;
\coordinate (\name-south)  at ( 0 , -\r, 0) ;

\path (\name-south) + (0,-20pt) coordinate (caption-node) 
edge ["\textcolor{black}{\bf \caption}"'] (caption-node); %Ball caption

},
/sphere/.search also={/tikz},
/sphere/.cd,
radius/.store       in=\radius,
scale/.store        in=\scale,
caption/.store      in=\caption,
name/.store         in=\name,
fill/.store         in=\fill,
logo/.store         in=\logo,
opacity/.store      in=\opacity,
logo=$\Sigma$,
fill=green,
opacity=0.10,
scale=0.2,
radius=0.5,
caption=,
name=,
}


================================================
FILE: layers/Box.sty
================================================
\ProvidesPackage{Box}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This Block can draw simple block of boxes with custom colors. 
% Can be used for conv, deconv etc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{Box/.pic={\tikzset{/boxblock/.cd,#1}
        \tikzstyle{box}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=\opacity, pic actions,fill=\fill]
        
        \pgfmathsetmacro{\y}{\cubey*\scale}
        \pgfmathsetmacro{\z}{\cubez*\scale}
   
        %Multiple concatenated boxes
        \foreach[count=\i,%
                 evaluate=\i as \xlabel using {array({\boxlabels},\i-1)},% 
                 evaluate=\unscaledx as \k using {\unscaledx*\scale+\prev}, remember=\k as \prev (initially 0)] 
                 \unscaledx in \cubex
        {
            \pgfmathsetmacro{\x}{\unscaledx*\scale}
            \coordinate (a) at (\k-\x , \y/2 , \z/2); 
            \coordinate (b) at (\k-\x ,-\y/2 , \z/2); 
            \coordinate (c) at (\k    ,-\y/2 , \z/2); 
            \coordinate (d) at (\k    , \y/2 , \z/2); 
            \coordinate (e) at (\k    , \y/2 ,-\z/2); 
            \coordinate (f) at (\k    ,-\y/2 ,-\z/2); 
            \coordinate (g) at (\k-\x ,-\y/2 ,-\z/2); 
            \coordinate (h) at (\k-\x , \y/2 ,-\z/2); 
        
            \draw [box] 
                (d) -- (a) -- (b) -- (c) -- cycle     
                (d) -- (a) -- (h) -- (e) -- cycle
                %dotted edges
                (f) edge (g)
                (b) edge (g)
                (h) edge (g)    
            ;
            \path (b) edge ["\xlabel"',midway] (c);
            
            \xdef\LastEastx{\k} %\k persists as \LastEastx after loop 
        }%Loop ends
        \draw [box] (d) -- (e) -- (f) -- (c) -- cycle; %East face of last box     
        
        \coordinate (a1) at (0 , \y/2 , \z/2);
        \coordinate (b1) at (0 ,-\y/2 , \z/2);
        \tikzstyle{depthlabel}=[pos=0,text width=14*\z,text centered,sloped]       
        
        \path (c) edge ["\small\zlabel"',depthlabel](f); %depth label
        \path (b1) edge ["\ylabel",midway] (a1);  %height label
        
        
        \tikzstyle{captionlabel}=[text width=15*\LastEastx/\scale,text centered]       
        \path (\LastEastx/2,-\y/2,+\z/2) + (0,-25pt) coordinate (cap) 
        edge ["\textcolor{black}{ \bf \caption}"',captionlabel](cap) ; %Block caption/pic object label
         
        %Define nodes to be used outside on the pic object
        \coordinate (\name-west)   at (0,0,0) ;
        \coordinate (\name-east)   at (\LastEastx, 0,0) ;
        \coordinate (\name-north)  at (\LastEastx/2,\y/2,0);
        \coordinate (\name-south)  at (\LastEastx/2,-\y/2,0);       
        \coordinate (\name-anchor) at (\LastEastx/2, 0,0) ;
        
        \coordinate (\name-near) at (\LastEastx/2,0,\z/2);
        \coordinate (\name-far)  at (\LastEastx/2,0,-\z/2);       
        
        \coordinate (\name-nearwest) at (0,0,\z/2);
        \coordinate (\name-neareast) at (\LastEastx,0,\z/2);
        \coordinate (\name-farwest)  at (0,0,-\z/2);
        \coordinate (\name-fareast)  at (\LastEastx,0,-\z/2);
        
        \coordinate (\name-northeast) at (\name-north-|\name-east);
        \coordinate (\name-northwest) at (\name-north-|\name-west);
        \coordinate (\name-southeast) at (\name-south-|\name-east);
        \coordinate (\name-southwest) at (\name-south-|\name-west);
        
        \coordinate (\name-nearnortheast)  at (\LastEastx, \y/2, \z/2);
        \coordinate (\name-farnortheast)   at (\LastEastx, \y/2,-\z/2);
        \coordinate (\name-nearsoutheast)  at (\LastEastx,-\y/2, \z/2);
        \coordinate (\name-farsoutheast)   at (\LastEastx,-\y/2,-\z/2);
        
        \coordinate (\name-nearnorthwest)  at (0, \y/2, \z/2);
        \coordinate (\name-farnorthwest)   at (0, \y/2,-\z/2);
        \coordinate (\name-nearsouthwest)  at (0,-\y/2, \z/2);
        \coordinate (\name-farsouthwest)   at (0,-\y/2,-\z/2);
        
    },
    /boxblock/.search also={/tikz},
    /boxblock/.cd,
    width/.store        in=\cubex,
    height/.store       in=\cubey,
    depth/.store        in=\cubez,
    scale/.store        in=\scale,
    xlabel/.store       in=\boxlabels,
    ylabel/.store       in=\ylabel,
    zlabel/.store       in=\zlabel,
    caption/.store      in=\caption,
    name/.store         in=\name,
    fill/.store         in=\fill,
    opacity/.store      in=\opacity,
    fill={rgb:red,5;green,5;blue,5;white,15},
    opacity=0.4,
    width=2,
    height=13,
    depth=15,
    scale=.2,
    xlabel={{"","","","","","","","","",""}},
    ylabel=,
    zlabel=,
    caption=,
    name=,
}


================================================
FILE: layers/RightBandedBox.sty
================================================
\ProvidesPackage{RightBandedBox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This Block can draw simple block of boxes with custom colors. 
% Can be used for conv, deconv etc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{RightBandedBox/.pic={\tikzset{/block/.cd,#1}
                
        \tikzstyle{box}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=\opacity, pic actions,fill=\fill]
        
        \tikzstyle{band}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=\bandopacity, pic actions,fill=\bandfill,draw=\bandfill]
        
        \pgfmathsetmacro{\y}{\cubey*\scale}
        \pgfmathsetmacro{\z}{\cubez*\scale}

        %Multiple concatenated boxes	 	  	
        \foreach[count=\i,%
                 evaluate=\i as \xlabel using {array({\boxlabels},\i-1)},% 
                 evaluate=\unscaledx as \k using {\unscaledx*\scale+\prev}, remember=\k as \prev (initially 0)] 
                 \unscaledx in \cubex
        {
            \pgfmathsetmacro{\x}{\unscaledx*\scale}
            \coordinate (a)     at (\k-\x   , \y/2 , \z/2); 
            \coordinate (art)   at (\k-\x/3 , \y/2 , \z/2); %a_right_third
            \coordinate (b)     at (\k-\x   ,-\y/2 , \z/2); 
            \coordinate (brt)   at (\k-\x/3 ,-\y/2 , \z/2); %b_right_third
            \coordinate (c)     at (\k      ,-\y/2 , \z/2); 
            \coordinate (d)     at (\k      , \y/2 , \z/2); 
            \coordinate (e)     at (\k      , \y/2 ,-\z/2); 
            \coordinate (f)     at (\k      ,-\y/2 ,-\z/2); 
            \coordinate (g)     at (\k-\x   ,-\y/2 ,-\z/2); 
            \coordinate (h)     at (\k-\x   , \y/2 ,-\z/2); 
            \coordinate (hrt)   at (\k-\x/3 , \y/2 ,-\z/2); %h_right_third
            
            %fill box color 			
            \draw [box] 
                (d) -- (a) -- (b) -- (c) -- cycle     
                (d) -- (a) -- (h) -- (e) -- cycle;
            %dotted edges
            \draw [box]
                (f) edge (g)
                (b) edge (g)
                (h) edge (g);
            %fill band color    
            \draw [band] 
                (d) -- (art) -- (brt) -- (c) -- cycle     
                (d) -- (art) -- (hrt) -- (e) -- cycle;
            %draw edges again which were covered by band
            \draw [box,fill opacity=0] 
                (d) -- (a) -- (b) -- (c) -- cycle     
                (d) -- (a) -- (h) -- (e) -- cycle;            
            	
            \path (b) edge ["\xlabel"',midway] (c);
            
            \xdef\LastEastx{\k} %\k persists as \LastEastx after loop 
        }%Loop ends
        \draw [box] (d) -- (e) -- (f) -- (c) -- cycle; %East face of last box
        \draw [band] (d) -- (e) -- (f) -- (c) -- cycle; %East face of last box 
        \draw [pic actions] (d) -- (e) -- (f) -- (c) -- cycle; %East face edges of last box     
        
        \coordinate (a1) at (0 , \y/2 , \z/2);
        \coordinate (b1) at (0 ,-\y/2 , \z/2);
        \tikzstyle{depthlabel}=[pos=0,text width=14*\z,text centered,sloped]       
        
        \path (c) edge ["\small\zlabels"',depthlabel](f); %depth label
        \path (b1) edge ["\ylabel",midway] (a1);  %height label 	  
        
        \tikzstyle{captionlabel}=[text width=15*\LastEastx/\scale,text centered] 
        \path (\LastEastx/2,-\y/2,+\z/2) + (0,-25pt) coordinate (cap) 
        edge ["\textcolor{black}{ \bf \caption}"',captionlabel] (cap); %Block caption/pic object label
         
        %Define nodes to be used outside on the pic object
        \coordinate (\name-west)   at (0,0,0) ;
        \coordinate (\name-east)   at (\LastEastx, 0,0) ;
        \coordinate (\name-north)  at (\LastEastx/2,\y/2,0);
        \coordinate (\name-south)  at (\LastEastx/2,-\y/2,0);       
        \coordinate (\name-anchor) at (\LastEastx/2, 0,0) ;
        
        \coordinate (\name-near) at (\LastEastx/2,0,\z/2);
        \coordinate (\name-far)  at (\LastEastx/2,0,-\z/2);       
        
        \coordinate (\name-nearwest) at (0,0,\z/2);
        \coordinate (\name-neareast) at (\LastEastx,0,\z/2);
        \coordinate (\name-farwest)  at (0,0,-\z/2);
        \coordinate (\name-fareast)  at (\LastEastx,0,-\z/2);
        
        \coordinate (\name-northeast) at (\name-north-|\name-east);
        \coordinate (\name-northwest) at (\name-north-|\name-west);
        \coordinate (\name-southeast) at (\name-south-|\name-east);
        \coordinate (\name-southwest) at (\name-south-|\name-west);
        
        \coordinate (\name-nearnortheast)  at (\LastEastx, \y/2, \z/2);
        \coordinate (\name-farnortheast)   at (\LastEastx, \y/2,-\z/2);
        \coordinate (\name-nearsoutheast)  at (\LastEastx,-\y/2, \z/2);
        \coordinate (\name-farsoutheast)   at (\LastEastx,-\y/2,-\z/2);
        
        \coordinate (\name-nearnorthwest)  at (0, \y/2, \z/2);
        \coordinate (\name-farnorthwest)   at (0, \y/2,-\z/2);
        \coordinate (\name-nearsouthwest)  at (0,-\y/2, \z/2);
        \coordinate (\name-farsouthwest)   at (0,-\y/2,-\z/2);
    },
    /block/.search also={/tikz},
    /block/.cd,
    width/.store        in=\cubex,
    height/.store       in=\cubey,
    depth/.store        in=\cubez,
    scale/.store        in=\scale,
    xlabel/.store       in=\boxlabels,
    ylabel/.store       in=\ylabel,
    zlabel/.store       in=\zlabels,
    caption/.store      in=\caption,
    name/.store         in=\name,
    fill/.store         in=\fill,
    bandfill/.store     in=\bandfill,
    opacity/.store      in=\opacity,
    bandopacity/.store  in=\bandopacity,
    fill={rgb:red,5;green,5;blue,5;white,15},
    bandfill={rgb:red,5;green,5;blue,5;white,5},
    opacity=0.4,
    bandopacity=0.6,
    width=2,
    height=13,
    depth=15,
    scale=.2,
    xlabel={{"","","","","","","","","",""}},
    ylabel=,
    zlabel=,
    caption=,
    name=,
}


================================================
FILE: layers/init.tex
================================================
%\ProvidesPackage{init}
\usetikzlibrary{quotes,arrows.meta}
\usetikzlibrary{positioning}

\def\edgecolor{rgb:blue,4;red,1;green,4;black,3}
\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);}

\usepackage{Ball}
\usepackage{Box}
\usepackage{RightBandedBox}



================================================
FILE: pycore/__init__.py
================================================


================================================
FILE: pycore/blocks.py
================================================

from .tikzeng import *

#define new block
def block_2ConvPool( name, botton, top, s_filer=256, n_filer=64, offset="(1,0,0)", size=(32,32,3.5), opacity=0.5 ):
    return [
    to_ConvConvRelu( 
        name="ccr_{}".format( name ),
        s_filer=str(s_filer), 
        n_filer=(n_filer,n_filer), 
        offset=offset, 
        to="({}-east)".format( botton ), 
        width=(size[2],size[2]), 
        height=size[0], 
        depth=size[1],   
        ),    
    to_Pool(         
        name="{}".format( top ), 
        offset="(0,0,0)", 
        to="(ccr_{}-east)".format( name ),  
        width=1,         
        height=size[0] - int(size[0]/4), 
        depth=size[1] - int(size[0]/4), 
        opacity=opacity, ),
    to_connection( 
        "{}".format( botton ), 
        "ccr_{}".format( name )
        )
    ]


def block_Unconv( name, botton, top, s_filer=256, n_filer=64, offset="(1,0,0)", size=(32,32,3.5), opacity=0.5 ):
    return [
        to_UnPool(  name='unpool_{}'.format(name),    offset=offset,    to="({}-east)".format(botton),         width=1,              height=size[0],       depth=size[1], opacity=opacity ),
        to_ConvRes( name='ccr_res_{}'.format(name),   offset="(0,0,0)", to="(unpool_{}-east)".format(name),    s_filer=str(s_filer), n_filer=str(n_filer), width=size[2], height=size[0], depth=size[1], opacity=opacity ),       
        to_Conv(    name='ccr_{}'.format(name),       offset="(0,0,0)", to="(ccr_res_{}-east)".format(name),   s_filer=str(s_filer), n_filer=str(n_filer), width=size[2], height=size[0], depth=size[1] ),
        to_ConvRes( name='ccr_res_c_{}'.format(name), offset="(0,0,0)", to="(ccr_{}-east)".format(name),       s_filer=str(s_filer), n_filer=str(n_filer), width=size[2], height=size[0], depth=size[1], opacity=opacity ),       
        to_Conv(    name='{}'.format(top),            offset="(0,0,0)", to="(ccr_res_c_{}-east)".format(name), s_filer=str(s_filer), n_filer=str(n_filer), width=size[2], height=size[0], depth=size[1] ),
        to_connection( 
            "{}".format( botton ), 
            "unpool_{}".format( name ) 
            )
    ]




def block_Res( num, name, botton, top, s_filer=256, n_filer=64, offset="(0,0,0)", size=(32,32,3.5), opacity=0.5 ):
    lys = []
    layers = [ *[ '{}_{}'.format(name,i) for i in range(num-1) ], top]
    for name in layers:        
        ly = [ to_Conv( 
            name='{}'.format(name),       
            offset=offset, 
            to="({}-east)".format( botton ),   
            s_filer=str(s_filer), 
            n_filer=str(n_filer), 
            width=size[2],
            height=size[0],
            depth=size[1]
            ),
            to_connection( 
                "{}".format( botton  ), 
                "{}".format( name ) 
                )
            ]
        botton = name
        lys+=ly
    
    lys += [
        to_skip( of=layers[1], to=layers[-2], pos=1.25),
    ]
    return lys




================================================
FILE: pycore/tikzeng.py
================================================

import os

def to_head( projectpath ):
    pathlayers = os.path.join( projectpath, 'layers/' ).replace('\\', '/')
    return r"""
\documentclass[border=8pt, multi, tikz]{standalone} 
\usepackage{import}
\subimport{"""+ pathlayers + r"""}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image 
"""

def to_cor():
    return r"""
\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}   
\def\SumColor{rgb:blue,5;green,15}
"""

def to_begin():
    return r"""
\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width=0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}

\begin{document}
\begin{tikzpicture}
\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]
"""

# layers definition

def to_input( pathfile, to='(-3,0,0)', width=8, height=8, name="temp" ):
    return r"""
\node[canvas is zy plane at x=0] (""" + name + """) at """+ to +""" {\includegraphics[width="""+ str(width)+"cm"+""",height="""+ str(height)+"cm"+"""]{"""+ pathfile +"""}};
"""

# Conv
def to_Conv( name, s_filer=256, n_filer=64, offset="(0,0,0)", to="(0,0,0)", width=1, height=40, depth=40, caption=" " ):
    return r"""
\pic[shift={"""+ offset +"""}] at """+ to +""" 
    {Box={
        name=""" + name +""",
        caption="""+ caption +r""",
        xlabel={{"""+ str(n_filer) +""", }},
        zlabel="""+ str(s_filer) +""",
        fill=\ConvColor,
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""

# Conv,Conv,relu
# Bottleneck
def to_ConvConvRelu( name, s_filer=256, n_filer=(64,64), offset="(0,0,0)", to="(0,0,0)", width=(2,2), height=40, depth=40, caption=" " ):
    return r"""
\pic[shift={ """+ offset +""" }] at """+ to +""" 
    {RightBandedBox={
        name="""+ name +""",
        caption="""+ caption +""",
        xlabel={{ """+ str(n_filer[0]) +""", """+ str(n_filer[1]) +""" }},
        zlabel="""+ str(s_filer) +""",
        fill=\ConvColor,
        bandfill=\ConvReluColor,
        height="""+ str(height) +""",
        width={ """+ str(width[0]) +""" , """+ str(width[1]) +""" },
        depth="""+ str(depth) +"""
        }
    };
"""



# Pool
def to_Pool(name, offset="(0,0,0)", to="(0,0,0)", width=1, height=32, depth=32, opacity=0.5, caption=" "):
    return r"""
\pic[shift={ """+ offset +""" }] at """+ to +""" 
    {Box={
        name="""+name+""",
        caption="""+ caption +r""",
        fill=\PoolColor,
        opacity="""+ str(opacity) +""",
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""

# unpool4, 
def to_UnPool(name, offset="(0,0,0)", to="(0,0,0)", width=1, height=32, depth=32, opacity=0.5, caption=" "):
    return r"""
\pic[shift={ """+ offset +""" }] at """+ to +""" 
    {Box={
        name="""+ name +r""",
        caption="""+ caption +r""",
        fill=\UnpoolColor,
        opacity="""+ str(opacity) +""",
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""



def to_ConvRes( name, s_filer=256, n_filer=64, offset="(0,0,0)", to="(0,0,0)", width=6, height=40, depth=40, opacity=0.2, caption=" " ):
    return r"""
\pic[shift={ """+ offset +""" }] at """+ to +""" 
    {RightBandedBox={
        name="""+ name + """,
        caption="""+ caption + """,
        xlabel={{ """+ str(n_filer) + """, }},
        zlabel="""+ str(s_filer) +r""",
        fill={rgb:white,1;black,3},
        bandfill={rgb:white,1;black,2},
        opacity="""+ str(opacity) +""",
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""


# ConvSoftMax
def to_ConvSoftMax( name, s_filer=40, offset="(0,0,0)", to="(0,0,0)", width=1, height=40, depth=40, caption=" " ):
    return r"""
\pic[shift={"""+ offset +"""}] at """+ to +""" 
    {Box={
        name=""" + name +""",
        caption="""+ caption +""",
        zlabel="""+ str(s_filer) +""",
        fill=\SoftmaxColor,
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""

# SoftMax
def to_SoftMax( name, s_filer=10, offset="(0,0,0)", to="(0,0,0)", width=1.5, height=3, depth=25, opacity=0.8, caption=" " ):
    return r"""
\pic[shift={"""+ offset +"""}] at """+ to +""" 
    {Box={
        name=""" + name +""",
        caption="""+ caption +""",
        xlabel={{" ","dummy"}},
        zlabel="""+ str(s_filer) +""",
        fill=\SoftmaxColor,
        opacity="""+ str(opacity) +""",
        height="""+ str(height) +""",
        width="""+ str(width) +""",
        depth="""+ str(depth) +"""
        }
    };
"""

def to_Sum( name, offset="(0,0,0)", to="(0,0,0)", radius=2.5, opacity=0.6):
    return r"""
\pic[shift={"""+ offset +"""}] at """+ to +""" 
    {Ball={
        name=""" + name +""",
        fill=\SumColor,
        opacity="""+ str(opacity) +""",
        radius="""+ str(radius) +""",
        logo=$+$
        }
    };
"""


def to_connection( of, to):
    return r"""
\draw [connection]  ("""+of+"""-east)    -- node {\midarrow} ("""+to+"""-west);
"""

def to_skip( of, to, pos=1.25):
    return r"""
\path ("""+ of +"""-southeast) -- ("""+ of +"""-northeast) coordinate[pos="""+ str(pos) +"""] ("""+ of +"""-top) ;
\path ("""+ to +"""-south)  -- ("""+ to +"""-north)  coordinate[pos="""+ str(pos) +"""] ("""+ to +"""-top) ;
\draw [copyconnection]  ("""+of+"""-northeast)  
-- node {\copymidarrow}("""+of+"""-top)
-- node {\copymidarrow}("""+to+"""-top)
-- node {\copymidarrow} ("""+to+"""-north);
"""

def to_end():
    return r"""
\end{tikzpicture}
\end{document}
"""


def to_generate( arch, pathname="file.tex" ):
    with open(pathname, "w") as f: 
        for c in arch:
            print(c)
            f.write( c )
     




================================================
FILE: pyexamples/test_simple.py
================================================

import sys
sys.path.append('../')
from pycore.tikzeng import *

# defined your arch
arch = [
    to_head( '..' ),
    to_cor(),
    to_begin(),
    to_Conv("conv1", 512, 64, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=2 ),
    to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)"),
    to_Conv("conv2", 128, 64, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=2 ),
    to_connection( "pool1", "conv2"), 
    to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=28, depth=28, width=1),
    to_SoftMax("soft1", 10 ,"(3,0,0)", "(pool1-east)", caption="SOFT"  ),
    to_connection("pool2", "soft1"),    
    to_Sum("sum1", offset="(1.5,0,0)", to="(soft1-east)", radius=2.5, opacity=0.6),
    to_connection("soft1", "sum1"),
    to_end()
    ]

def main():
    namefile = str(sys.argv[0]).split('.')[0]
    to_generate(arch, namefile + '.tex' )

if __name__ == '__main__':
    main()


================================================
FILE: pyexamples/unet.py
================================================

import sys
sys.path.append('../')
from pycore.tikzeng import *
from pycore.blocks  import *

arch = [ 
    to_head('..'), 
    to_cor(),
    to_begin(),
    
    #input
    to_input( '../examples/fcn8s/cats.jpg' ),

    #block-001
    to_ConvConvRelu( name='ccr_b1', s_filer=500, n_filer=(64,64), offset="(0,0,0)", to="(0,0,0)", width=(2,2), height=40, depth=40  ),
    to_Pool(name="pool_b1", offset="(0,0,0)", to="(ccr_b1-east)", width=1, height=32, depth=32, opacity=0.5),
    
    *block_2ConvPool( name='b2', botton='pool_b1', top='pool_b2', s_filer=256, n_filer=128, offset="(1,0,0)", size=(32,32,3.5), opacity=0.5 ),
    *block_2ConvPool( name='b3', botton='pool_b2', top='pool_b3', s_filer=128, n_filer=256, offset="(1,0,0)", size=(25,25,4.5), opacity=0.5 ),
    *block_2ConvPool( name='b4', botton='pool_b3', top='pool_b4', s_filer=64,  n_filer=512, offset="(1,0,0)", size=(16,16,5.5), opacity=0.5 ),

    #Bottleneck
    #block-005
    to_ConvConvRelu( name='ccr_b5', s_filer=32, n_filer=(1024,1024), offset="(2,0,0)", to="(pool_b4-east)", width=(8,8), height=8, depth=8, caption="Bottleneck"  ),
    to_connection( "pool_b4", "ccr_b5"),

    #Decoder
    *block_Unconv( name="b6", botton="ccr_b5", top='end_b6', s_filer=64,  n_filer=512, offset="(2.1,0,0)", size=(16,16,5.0), opacity=0.5 ),
    to_skip( of='ccr_b4', to='ccr_res_b6', pos=1.25),
    *block_Unconv( name="b7", botton="end_b6", top='end_b7', s_filer=128, n_filer=256, offset="(2.1,0,0)", size=(25,25,4.5), opacity=0.5 ),
    to_skip( of='ccr_b3', to='ccr_res_b7', pos=1.25),    
    *block_Unconv( name="b8", botton="end_b7", top='end_b8', s_filer=256, n_filer=128, offset="(2.1,0,0)", size=(32,32,3.5), opacity=0.5 ),
    to_skip( of='ccr_b2', to='ccr_res_b8', pos=1.25),    
    
    *block_Unconv( name="b9", botton="end_b8", top='end_b9', s_filer=512, n_filer=64,  offset="(2.1,0,0)", size=(40,40,2.5), opacity=0.5 ),
    to_skip( of='ccr_b1', to='ccr_res_b9', pos=1.25),
    
    to_ConvSoftMax( name="soft1", s_filer=512, offset="(0.75,0,0)", to="(end_b9-east)", width=1, height=40, depth=40, caption="SOFT" ),
    to_connection( "end_b9", "soft1"),
     
    to_end() 
    ]


def main():
    namefile = str(sys.argv[0]).split('.')[0]
    to_generate(arch, namefile + '.tex' )

if __name__ == '__main__':
    main()
    


================================================
FILE: tikzmake.sh
================================================
#!/bin/bash


python $1.py 
pdflatex $1.tex

rm *.aux *.log *.vscodeLog
rm *.tex

if [[ "$OSTYPE" == "darwin"* ]]; then
    open $1.pdf
else
    xdg-open $1.pdf
fi
Download .txt
gitextract_mf86ygiw/

├── .gitignore
├── .idea/
│   ├── misc.xml
│   ├── modules.xml
│   ├── plotneuralnet.iml
│   ├── vcs.xml
│   └── workspace.xml
├── LICENSE
├── README.md
├── examples/
│   ├── AlexNet/
│   │   └── alexnet.tex
│   ├── HED/
│   │   └── HED.tex
│   ├── LeNet/
│   │   ├── lenet.tex
│   │   └── lenet.txt
│   ├── SoftmaxLoss/
│   │   └── SoftmaxLoss.tex
│   ├── Unet/
│   │   └── Unet.tex
│   ├── Unet_Ushape/
│   │   └── Unet_ushape.tex
│   ├── VGG16/
│   │   └── vgg16.tex
│   ├── fcn32s/
│   │   └── fcn32.tex
│   └── fcn8s/
│       └── fcn8.tex
├── layers/
│   ├── Ball.sty
│   ├── Box.sty
│   ├── RightBandedBox.sty
│   └── init.tex
├── pycore/
│   ├── __init__.py
│   ├── blocks.py
│   └── tikzeng.py
├── pyexamples/
│   ├── test_simple.py
│   └── unet.py
└── tikzmake.sh
Download .txt
SYMBOL INDEX (21 symbols across 4 files)

FILE: pycore/blocks.py
  function block_2ConvPool (line 5) | def block_2ConvPool( name, botton, top, s_filer=256, n_filer=64, offset=...
  function block_Unconv (line 32) | def block_Unconv( name, botton, top, s_filer=256, n_filer=64, offset="(1...
  function block_Res (line 48) | def block_Res( num, name, botton, top, s_filer=256, n_filer=64, offset="...

FILE: pycore/tikzeng.py
  function to_head (line 4) | def to_head( projectpath ):
  function to_cor (line 14) | def to_cor():
  function to_begin (line 26) | def to_begin():
  function to_input (line 38) | def to_input( pathfile, to='(-3,0,0)', width=8, height=8, name="temp" ):
  function to_Conv (line 44) | def to_Conv( name, s_filer=256, n_filer=64, offset="(0,0,0)", to="(0,0,0...
  function to_ConvConvRelu (line 62) | def to_ConvConvRelu( name, s_filer=256, n_filer=(64,64), offset="(0,0,0)...
  function to_Pool (line 82) | def to_Pool(name, offset="(0,0,0)", to="(0,0,0)", width=1, height=32, de...
  function to_UnPool (line 98) | def to_UnPool(name, offset="(0,0,0)", to="(0,0,0)", width=1, height=32, ...
  function to_ConvRes (line 115) | def to_ConvRes( name, s_filer=256, n_filer=64, offset="(0,0,0)", to="(0,...
  function to_ConvSoftMax (line 135) | def to_ConvSoftMax( name, s_filer=40, offset="(0,0,0)", to="(0,0,0)", wi...
  function to_SoftMax (line 151) | def to_SoftMax( name, s_filer=10, offset="(0,0,0)", to="(0,0,0)", width=...
  function to_Sum (line 168) | def to_Sum( name, offset="(0,0,0)", to="(0,0,0)", radius=2.5, opacity=0.6):
  function to_connection (line 182) | def to_connection( of, to):
  function to_skip (line 187) | def to_skip( of, to, pos=1.25):
  function to_end (line 197) | def to_end():
  function to_generate (line 204) | def to_generate( arch, pathname="file.tex" ):

FILE: pyexamples/test_simple.py
  function main (line 23) | def main():

FILE: pyexamples/unet.py
  function main (line 46) | def main():
Condensed preview — 28 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (97K chars).
[
  {
    "path": ".gitignore",
    "chars": 983,
    "preview": "*.aux\n*.log\n*.gz\n\n__pycache__\nbooks\nproject\n\n# PyInstaller\n#  Usually these files are written by a python script from a "
  },
  {
    "path": ".idea/misc.xml",
    "chars": 209,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectRootManager\" version=\"2\" project-"
  },
  {
    "path": ".idea/modules.xml",
    "chars": 278,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n   "
  },
  {
    "path": ".idea/plotneuralnet.iml",
    "chars": 459,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"PYTHON_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager"
  },
  {
    "path": ".idea/vcs.xml",
    "chars": 180,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping dire"
  },
  {
    "path": ".idea/workspace.xml",
    "chars": 7562,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ChangeListManager\">\n    <list default=\"t"
  },
  {
    "path": "LICENSE",
    "chars": 1069,
    "preview": "MIT License\n\nCopyright (c) 2018 HarisIqbal88\n\nPermission is hereby granted, free of charge, to any person obtaining a co"
  },
  {
    "path": "README.md",
    "chars": 3397,
    "preview": "# PlotNeuralNet\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2526396.svg)](https://doi.org/10.5281/zenodo.2526396"
  },
  {
    "path": "examples/AlexNet/alexnet.tex",
    "chars": 4486,
    "preview": "\\documentclass[border=8pt, multi, tikz]{standalone} \r\n\\usepackage{import}\r\n\\subimport{../layers/}{init}\r\n\\usetikzlibrary"
  },
  {
    "path": "examples/HED/HED.tex",
    "chars": 7066,
    "preview": "\\documentclass[border=15pt, multi, tikz]{standalone}\n\\usepackage{import}\n\\subimport{../../layers/}{init}\n\\usetikzlibrary"
  },
  {
    "path": "examples/LeNet/lenet.tex",
    "chars": 3276,
    "preview": "\\documentclass[border=8pt, multi, tikz]{standalone} \r\n\\usepackage{import}\r\n\\subimport{../layers/}{init}\r\n\\usetikzlibrary"
  },
  {
    "path": "examples/LeNet/lenet.txt",
    "chars": 135,
    "preview": "input(32, 32, 1)\r\nconv(28, 28, 6)\r\npool(14, 14, 6)\r\nconv(10, 10, 16)\r\npool(5, 5, 16)\r\nconv(1,1,120)\r\nfullyconn(1,1,84)\r\n"
  },
  {
    "path": "examples/SoftmaxLoss/SoftmaxLoss.tex",
    "chars": 2032,
    "preview": "\\documentclass[border=15pt, multi, tikz]{standalone}\n\\usepackage{import}\n\\subimport{../../layers/}{init}\n\\usetikzlibrary"
  },
  {
    "path": "examples/Unet/Unet.tex",
    "chars": 8413,
    "preview": "\\documentclass[border=8pt, multi, tikz]{standalone}\n%\\usepackage{blocks}\n\\usepackage{import}\n\\subimport{../../layers/}{i"
  },
  {
    "path": "examples/Unet_Ushape/Unet_ushape.tex",
    "chars": 8302,
    "preview": "\\documentclass[border=8pt, multi, tikz]{standalone}\n%\\usepackage{blocks}\n\\usepackage{import}\n\\subimport{../../layers/}{i"
  },
  {
    "path": "examples/VGG16/vgg16.tex",
    "chars": 4821,
    "preview": "\\documentclass[border=15pt, multi, tikz]{standalone}\n%\\usepackage{blocks}\n\\usepackage{import}\n\\subimport{../../layers/}{"
  },
  {
    "path": "examples/fcn32s/fcn32.tex",
    "chars": 4585,
    "preview": "\\documentclass[border=15pt, multi, tikz]{standalone}\n\\usepackage{import}\n\\subimport{../../layers/}{init}\n\\usetikzlibrary"
  },
  {
    "path": "examples/fcn8s/fcn8.tex",
    "chars": 6608,
    "preview": "\\documentclass[border=15pt, multi, tikz]{standalone}\n\\usepackage{import}\n\\subimport{../../layers/}{init}\n\\usetikzlibrary"
  },
  {
    "path": "layers/Ball.sty",
    "chars": 1197,
    "preview": "\\ProvidesPackage{Ball}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n%This Block can draw small Ball\r\n%E"
  },
  {
    "path": "layers/Box.sty",
    "chars": 4868,
    "preview": "\\ProvidesPackage{Box}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% This "
  },
  {
    "path": "layers/RightBandedBox.sty",
    "chars": 6111,
    "preview": "\\ProvidesPackage{RightBandedBox}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
  },
  {
    "path": "layers/init.tex",
    "chars": 318,
    "preview": "%\\ProvidesPackage{init}\r\n\\usetikzlibrary{quotes,arrows.meta}\r\n\\usetikzlibrary{positioning}\r\n\r\n\\def\\edgecolor{rgb:blue,4;"
  },
  {
    "path": "pycore/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "pycore/blocks.py",
    "chars": 2946,
    "preview": "\nfrom .tikzeng import *\n\n#define new block\ndef block_2ConvPool( name, botton, top, s_filer=256, n_filer=64, offset=\"(1,0"
  },
  {
    "path": "pycore/tikzeng.py",
    "chars": 6294,
    "preview": "\nimport os\n\ndef to_head( projectpath ):\n    pathlayers = os.path.join( projectpath, 'layers/' ).replace('\\\\', '/')\n    r"
  },
  {
    "path": "pyexamples/test_simple.py",
    "chars": 919,
    "preview": "\nimport sys\nsys.path.append('../')\nfrom pycore.tikzeng import *\n\n# defined your arch\narch = [\n    to_head( '..' ),\n    t"
  },
  {
    "path": "pyexamples/unet.py",
    "chars": 2304,
    "preview": "\nimport sys\nsys.path.append('../')\nfrom pycore.tikzeng import *\nfrom pycore.blocks  import *\n\narch = [ \n    to_head('..'"
  },
  {
    "path": "tikzmake.sh",
    "chars": 164,
    "preview": "#!/bin/bash\n\n\npython $1.py \npdflatex $1.tex\n\nrm *.aux *.log *.vscodeLog\nrm *.tex\n\nif [[ \"$OSTYPE\" == \"darwin\"* ]]; then\n"
  }
]

About this extraction

This page contains the full source code of the HarisIqbal88/PlotNeuralNet GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 28 files (86.9 KB), approximately 30.4k tokens, and a symbol index with 21 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!