Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a python package #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.idea/
*.pyc
dist/
build/
plotnn.egg-info/
pyexamples/*.pdf

*.aux
*.log
*.gz
Expand Down
4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/plotneuralnet.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

110 changes: 0 additions & 110 deletions .idea/workspace.xml

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include latexnn/static/*
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,45 @@ Latex code for drawing neural networks for reports and presentation. Have a look
- [ ] Add easy legend functionality
- [ ] Add more layer shapes like TruncatedPyramid, 2DSheet etc
- [ ] Add examples for RNN and likes.
- [ ] Auto offset and size calculation


## Latex Usage
see examples

## PyUsage
## Python usage

### Installation

Only support Python3.

python3 setup.py install

### Write NN layout

mkdir my_project
cd my_project
vim my_arch.py
The network layout looks like

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

# defined your arch
arch = [
to_head( '..' ),
to_cor(),
to_begin(),
# defined your arch
arch = [
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' )
def main():
namefile = str(sys.argv[0]).split('.')[0]
to_pdf(arch, namefile + '.pdf' )

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

bash ../tikzmake.sh my_arch
Then run `python <your_script>.py` to generate `<nn>.pdf` (replace `<nn>` with your file name).

## Examples

Expand Down
2 changes: 1 addition & 1 deletion examples/HED/HED.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
Expand Down
2 changes: 1 addition & 1 deletion examples/SoftmaxLoss/SoftmaxLoss.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\newcommand{\up}{0.25}
Expand Down
2 changes: 1 addition & 1 deletion examples/Unet/Unet.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
Expand Down
2 changes: 1 addition & 1 deletion examples/Unet_Ushape/Unet_ushape.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
Expand Down
2 changes: 1 addition & 1 deletion examples/VGG16/vgg16.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[border=15pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
Expand Down
2 changes: 1 addition & 1 deletion examples/fcn32s/fcn32.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
Expand Down
2 changes: 1 addition & 1 deletion examples/fcn8s/fcn8.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\documentclass[border=15pt, multi, tikz]{standalone}
\usepackage{import}
\subimport{../../layers/}{init}
\subimport{../../static/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image

Expand Down
3 changes: 3 additions & 0 deletions latexnn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .tikzeng import *
from .blocks import *
from .layers import *
2 changes: 1 addition & 1 deletion pycore/blocks.py → latexnn/blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from .tikzeng import *
from .layers 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 ):
Expand Down
Loading