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.
- If layer setting is not defined default box will be drawn
- You can change color of layers
- Easy color usage
- Arrow modification
- Automatic legend
- Add examples
-
Install the following packages on Ubuntu.
-
Ubuntu 16.04
sudo apt-get install texlive-latex-extra
-
Ubuntu 18.04.2 Base on this website, 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
- Download and install MikTeX.
- Download and install bash runner on Windows, recommends Git bash or Cygwin(https://www.cygwin.com/)
-
Mac
Install MacTex from here.
-
import sys
sys.path.append('..')
from core.texpage import *
import subprocess
# Define tex page
page = TexPage()
# Add layers to model
page.model.addLayer('Conv2D','c1', 2, 64, 64)
page.model.addLayer('MaxPool', 'pool1', 2, 32, 32)
page.model.addLayer('Conv2D', 'c2', 2, 32, 32)
page.model.addLayer('MaxPool', 'pool2', 1, 28, 28)
page.model.addLayer('SoftMax', 'soft', 1, 28, 28)
page.model.addConnection('pool1', 'c2')
page.model.addConnection('pool2', 'soft')
# Create tex file
namefile = str(sys.argv[0]).split('.')[0]
page.generate(namefile + '.tex' )
# Run tex to get pdf
return_value = subprocess.call(['pdflatex', namefile + '.tex'], shell=False)
Following are some network representations: