harisiqbal88 / plotneuralnet Goto Github PK
View Code? Open in Web Editor NEWLatex code for making neural networks diagrams
License: MIT License
Latex code for making neural networks diagrams
License: MIT License
Thanks to devs for developing this useful library.
However, I'm a pure layman to latex. Is there any version check for latex or some required python libraries?
TY.
python my_arch.py
works fine, producing the output included below. However, when I run pdflatex
, I get error:
! I can't find file `tikzlibraryquotes.code.tex'.
<argument> ...nput tikzlibrary\pgf@temp .code.tex
\catcode `\@ =\csname tikz...
l.2 \usetikzlibrary{quotes,arrows.meta}
I presume this is a simple fix requiring an install. Please may you help me diagnose what I need installed on my system for this to run? I am able to run tikz fine and create examples e.g. this one.
$ pdflatex --version
pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
kpathsea version 6.1.1
Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.2.50; using libpng 1.2.50
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.24.5
\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=conv1,
caption= ,
xlabel={{64, }},
zlabel=512,
fill=\ConvColor,
height=64,
width=2,
depth=64
}
};
\pic[shift={ (0,0,0) }] at (conv1-east)
{Box={
name=pool1,
caption= ,
fill=\PoolColor,
opacity=0.5,
height=32,
width=1,
depth=32
}
};
\pic[shift={(1,0,0)}] at (pool1-east)
{Box={
name=conv2,
caption= ,
xlabel={{64, }},
zlabel=128,
fill=\ConvColor,
height=32,
width=2,
depth=32
}
};
\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=28,
width=1,
depth=28
}
};
\pic[shift={(3,0,0)}] at (pool1-east)
{Box={
name=soft1,
caption=SOFT,
xlabel={{" ","dummy"}},
zlabel=10,
fill=\SoftmaxColor,
opacity=0.8,
height=3,
width=1.5,
depth=25
}
};
\draw [connection] (pool2-east) -- node {\midarrow} (soft1-west);
\end{tikzpicture}
\end{document}
Thanks for the awesome work!
Apparently the Box.sty file is missing the \coordinate (\name-top) definition.
How can I darw the line like between upper point of a plane, not the center point between two plane?
Hi, is there a way to visualize transfer learning? means two parallel network and connections between them? or some hack in mind?
Thanks!
Thank you for your publish code. Can you add code of FCN-8 or shorcut connection code?
On windows, the path is connected by \
rather than /
, which may cause some latex environment not recognize the subimport path correctly, e.g. on my machine (python 3.7 win10 x64), it produce
\subimport{..\layers/}{init}
but latexpdf complains about not find the path, it should be
\subimport{../layers/}{init}
I want to draw a model with 3 convolutional layer inputs and Integrated into the fully connected layer.How can I do this?
Congratulations on a wonderful project.
Would you be able to provide the Python code for Unet_Ushape and the other examples for which it is not currently provided?
Thanks much -- Ian
Hello!
Thank you for your project, I love it!
I'm working on a VGG19 network and I want to update your code of VGG16 but I can't find the python code. Can you upload it please?
Kind regards
It is an awesome project.
It is recommended to generate latex codes with pylatex
, that makes the codes readable and extensible. Of course, you have to spend some time on it.
Hello,
thank you for this awesome project. If I draw only one conv layer like this:
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,caption=conv1,%
xlabel={{"96", ""}},ylabel=224,zlabel=224,fill=\ConvColor,bandfill=\ConvReluColor,%
height=40,width={2},depth=40}};
then I have to keep xlabel as xlabel={{"96", ""}}
with an empty qoutation marks. Is there a way to eliminate this need?
how to change the color of layer box from black to white or any other color. thanks.
Hey there,
great work !
I got just a small suggestion, the script ../tikzmake.sh
hardcodes the evince
pdf reader. However, not everybody uses that one.
Could I just change that like to:
#!/bin/bash
python $1.py
pdflatex $1.tex
rm *.aux *.log *.vscodeLog
rm *.tex
xdg-open $1.pdf
In order to be a bit more compatible, even though thats a small issue
In the examples section of the readme, the figure displayed is not VGG16, it is a FCN without the skip connections
Is it possible to change the thickness of the edges along a shape (such as a Box)? If so, how?
Thanks!
Will it be possible to get .tex for ResNet50?
When I am trying to define the architecture in python example: arch.py and then use the command "./tikzmake.sh arch" it is not working and giving me the following error:
Traceback (most recent call last):
File "arch.py", line 4, in
from pycore.tikzeng import *
ModuleNotFoundError: No module named 'pycore.tikzeng'
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
! I can't find file `arch.tex'.
<*> arch.tex(Press Enter to retry, or Control-D to exit)
Please type another input file name:
Unfortunately I'm not sure about the syntax in python.
And i don't want to change it every time in Latex.
\draw [connection] (dense_1-west) -- node {\midarrow} (reshape_1-east);
Thank you,
Vaclav
I tried to let the Box block's edges be invisible via fill=\fill, draw=\fill
in Box.sty.
Actually, It only let edges AH, AD, DE, CD, EF and HE invisible.
Finally I found that \path (b) edge ["\bf\xlabel"', midway] (c);
created a solid line in BC, so do AB and CF.
I have no idea to fix this and I don't know why the solid lines emerged though no pic action acted in above code.
Furthermore, I want customize the style of draw line, but nothing changes after I put thin
into "box" style setting.
arch = [
to_head( '..' ),
to_cor(),
to_begin(),
to_Conv("conv1", 320, 8, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=8),
to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)", height=60, depth=60, width=1),
to_Conv("conv2", 160, 16, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=16),
to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=30, depth=30, width=1),
to_Conv("conv3", 80, 32, offset="(0,0,0)", to="(pool2-east)", height=16, depth=16, width=32),
to_Pool("pool3", offset="(0,0,0)", to="(conv3-east)", height=1, depth=1, width=32, caption='GlobalAveragePooling'),
to_SoftMax("soft1", 8 ,"(0,0,0)", "(pool3-east)", caption="fc1"),
to_connection( "soft2", "soft1"),
to_SoftMax("soft2", 1 ,"(1,0,0)", "(soft1-east)", caption="fc2", height=1, width=1, depth=1),
to_end()
]
The above makes a green arrow through the whole network instead of the last 2 layers. Why?
Thank you very much for your great work.
I want to draw the network structure of HED, but it has not been successful for a long time.
Can anyone share the original code of drawing HED? The deadline is coming. T-T
I'll be grateful.
Hi. I was working with your code (great, by the way!) and, while using "to_ConvConvRelu", I realized that it could be easily be extended to any number of Convs:
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={{ """+ ''.join([str(n_filer[i]) + """, """ for i in range(len(n_filer)-1)])+ str(n_filer[-1]) +""" }},
zlabel="""+ str(s_filer) +""",
fill=\ConvColor,
bandfill=\ConvReluColor,
height="""+ str(height) +""",
width={ """+ ''.join([str(width[i]) + """, """ for i in range(len(width)-1)])+ str(width[-1]) +""" },
depth="""+ str(depth) +"""
}
};
"""
Sorry for the not really clean code; there's surely a way of coding it that is not as dirty but it does the trick.
Regards,
Guille
I would like to connect the input image to conv blocks and other blocks, but it is not possible since to_input(...)
doesn't have east, west, northeast, etc... properties. How to solve this? Maybe wrap to_input(...)
in a box or something?
Referencing #26, worth guarding against silly issues like mine by simply insisting that the user has a recent version of pdflatex
.
In my issue I show that 2013 pdflatex
does not work, and 2018
does.
Hi, thank you for this awesome project! I am new to LaTex and just wondering is there any way for me to define or change the fontsize for the caption or the depthlabel? Thanks you!
Nice project! A batch normalization element would be cool...
Hi,
first of all let me say the visualization you have created here is looking excellent! I was thinking about using it, but I have noticed that there is no license included in the project. Could you please add one? You could check out choosealicense.com if you are unsure which license fits your needs.
Thank you very much.
Importing the 'layers' folder in a latex project will affect captions in every figure and table boxes. Basically, every caption will not have anymore the text "Figure X"/"Table X" where X is a index as soon as you add the lines \subimport{layers/}{init}
.
Minimum example (correct):
\documentclass{article}
\usepackage{graphicx}
% \usepackage{tikz}
% \usepackage{import}
% \subimport{layers/}{init}
% \usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\includegraphics[height=5cm]{cats.jpg}
\caption{This is a caption.}
\label{test2}
\end{figure}
\end{document}
Importing layers:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{import}
\subimport{layers/}{init}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\includegraphics[height=5cm]{cats.jpg}
\caption{This is a caption.}
\label{test2}
\end{figure}
\end{document}
Issues so are:
not displaying anymore the count of captions and not keeping the correct alignment.
Thank you for your work and how to draw a grid feature map?
Hi~ Thanks for your awesome contribution, it looks so cool for CNN related models!!!
but, can you give some examples like RNN/Stacked RNN/Transformer etc. really appreciate it
Does anyone know how to change the font size in the graph? I tried to simply add to the documentclass
\documentclass[border=15pt, multi, tikz]{standalone}
but it doesn't work and returns some errors with positioning.
Hello
How do you want us to cite your work?
In .tex file \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}};
but height ,width and depth ,how to initialize and change ?
Hi awesome team,
I was trying to run example in the readme, was able to get the latex printed out in terminal but...
../tikzmake.sh: line 5: pdflatex: command not found
rm: *.aux: No such file or directory
rm: *.log: No such file or directory
rm: *.vscodeLog: No such file or directory
../tikzmake.sh: line 10: evince: command not found
line 5: pdflatex: command not found
Is there a way to not use these two?
Thanks for your amazing work!
I am confused with the quotation mark like "\cubezlabel"'
. What is the difference between "\cubezlabel"
.
Looking forwarding your answer:)
pyexamples|master⚡ ⇒ bash ../tikzmake.sh unet
File "unet.py", line 19
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 ),
^
SyntaxError: invalid syntax
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
! I can't find file `unet.tex'.
<> unet.tex
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ^D
! Emergency stop.
<*> unet.tex
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
rm: *.aux: No such file or directory
rm: *.vscodeLog: No such file or directory
rm: *.tex: No such file or directory
../tikzmake.sh: line 10: xdg-open: command not found
Closed
May you add an example for U-Net architecture?
Thanks!
After running
pip install pycore
when I try to run in python:
from pycore.tikzeng import *
I got:
ModuleNotFoundError: No module named 'pycore.tikzeng'
Version: pycore==17.4.17
Hi,
Great library, very useful. I am writing a book for Cambridge University Press and would like to use it to explain CNNs. One feature that's missing is drawing the kernel dimensions (e.g. 3x3 or 5x5 or 11x11). Do you have any suggestions how to do that?
Michel
Hi, @HarisIqbal88
I am back again 😸 ! I found that labeling a caption will make a black dot by the following code. Though it's invisible on my Mac OS and Ubuntu, I found it when I open the pdf on Windows, using Adobe reader exactly.
\path (\LastEastx/2,-\y/2,+\z/2) + (0,-25pt) coordinate (cap)
edge ["\textcolor{black}{ \bf \caption}"',captionlabel](cap) ; %Block caption/pic object label
I am wondering that the way you make labels by adding a edge, but the tutorials in TiKz always use node
, which seems malfunctioned in your repo. (Maybe I use the node
syntax wrongly)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.