Skip to content

Commit

Permalink
tikz: Cascade correlation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed May 17, 2017
1 parent cb58e0a commit d436e1f
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tikz/cascade-correlation-network/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SOURCE = cascade-correlation-network
DELAY = 80
DENSITY = 300
WIDTH = 512

make:
pdflatex $(SOURCE).tex -output-format=pdf
make clean

clean:
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot

gif:
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean

png:
make
make svg
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png

transparentGif:
convert $(SOURCE).pdf -transparent white result.gif
make clean

svg:
make
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
pdf2svg $(SOURCE).pdf $(SOURCE).svg
# Necessary, as pdf2svg does not always create valid svgs:
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
rm $(SOURCE)2.svg
3 changes: 3 additions & 0 deletions tikz/cascade-correlation-network/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Compiled example
----------------
![Example](cascade-correlation-network.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions tikz/cascade-correlation-network/cascade-correlation-network.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes, calc, shapes, arrows, snakes}
\newcommand{\width}{0.2}
\begin{document}
\begin{preview}
\tikzset{sigmoid/.style={path picture= {
\begin{scope}[x=1pt,y=10pt]
\draw plot[domain=-7:7] (\x,{1/(1 + exp(-\x))-0.5});
\end{scope}
}
}
}

\tikzset{relu/.style={path picture= {
\begin{scope}[x=7pt,y=6pt]
\draw plot[domain=-1:0] (\x,0);
\draw plot[domain=0:1] (\x,\x);
\end{scope}
}
}
}

\tikzstyle{input}=[draw,fill=red!50,circle,minimum size=20pt,inner sep=0pt]
\tikzstyle{hidden}=[draw,fill=green!50,circle,minimum size=20pt,inner sep=0pt]
\tikzstyle{output}=[draw,fill=white,circle,minimum size=20pt,inner sep=0pt]
\tikzstyle{bias}=[draw,dashed,fill=gray!50,circle,minimum size=20pt,inner sep=0pt]
\tikzstyle{layer}=[fill=gray!70]

\tikzstyle{stateTransition}=[->, very thick]

\begin{tikzpicture}[scale=2]

\node (i0)[bias] at (0, 0) {1};
\node (i1)[input] at (0, 0.5) {};
\node (i2)[input] at (0, 1.0) {};
\node (i3)[input] at (0, 1.5) {};

\node (h1)[hidden] at (1, 2.0) {};
\node (h2)[hidden] at (2, 2.5) {};
\node (h3)[hidden] at (3, 3.0) {};

\node (o1)[output] at (4, 3.5) {};
\node (o2)[output] at (5, 3.5) {};

\draw[stateTransition] (i0) -- (6, 0);
\draw[stateTransition] (i1) -- (6, 0.5);
\draw[stateTransition] (i2) -- (6, 1.0);
\draw[stateTransition] (i3) -- (6, 1.5);
\draw[stateTransition] (h1) -- (6, 2.0);
\draw[stateTransition] (h2) -- (6, 2.5);
\draw[stateTransition] (h3) -- (6, 3.0);

\draw[stateTransition] (1, 0) -- (h1);
\draw[stateTransition] (2, 0) -- (h2);
\draw[stateTransition] (3, 0) -- (h3);

\draw[stateTransition] (4, 0) -- (o1);
\draw[stateTransition] (5, 0) -- (o2);

\foreach \x in {1,...,3} {
\pgfmathsetmacro{\limy}{(2+\x) / 2}
\foreach \y in {0, 0.5, ..., \limy} {
\node[rectangle,draw=black,fill=black,minimum size=12] (box) at (\x,\y) {};
}
}

\foreach \x in {4,...,5} {
\foreach \y in {0, ..., 6} {
\pgfmathsetmacro{\yn}{0.5*\y}
\node[rectangle,draw=black,fill=white,minimum size=12] (box) at (\x,\yn) {};
}
}

% \node (h11)[hidden, sigmoid] at (1, 1.5) {};
% \node (h12)[hidden, sigmoid] at (1, 0.5) {};
% \node[circle, inner sep=0] (h13) at (1,-0.5) {\vdots};
% \node (h14)[hidden, sigmoid] at (1,-1.5) {};
% \node (h21)[hidden, relu] at (2, 1.5) {};
% \node (h22)[hidden, relu] at (2, 0.5) {};
% \node[circle, inner sep=0] (h23) at (2,-0.5) {\vdots};
% \node (h24)[hidden, relu] at (2,-1.5) {};

% \node (o1)[output, sigmoid] at (3,0) {};

% \draw[stateTransition] (r) -- (h11) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (r) -- (h12) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (r) -- (h13) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (r) -- (h14) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (g) -- (h11) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (g) -- (h12) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (g) -- (h13) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (g) -- (h14) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (b) -- (h11) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (b) -- (h12) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (b) -- (h13) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (b) -- (h11) node [midway,above=-0.06cm] {};

% \draw[stateTransition] (h11) -- (h21) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h11) -- (h22) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h11) -- (h23) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h11) -- (h24) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h12) -- (h21) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h12) -- (h22) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h12) -- (h23) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h12) -- (h24) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h13) -- (h21) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h13) -- (h22) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h13) -- (h23) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h13) -- (h24) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h14) -- (h21) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h14) -- (h22) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h14) -- (h23) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h14) -- (h21) node [midway,above=-0.06cm] {};

% \draw[stateTransition] (h21) -- (o1) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h22) -- (o1) node [midway,above=-0.10cm] {};
% \draw[stateTransition] (h23) -- (o1) node [midway,above=-0.06cm] {};
% \draw[stateTransition] (h24) -- (o1) node [midway,above=-0.06cm] {};

% \draw [
% thick,
% decoration={
% brace,
% mirror,
% raise=0.5cm
% },
% decorate
% ] (1+-\width, -1.8) -- (2+\width, -1.8)
% node [pos=0.5,anchor=north,yshift=-0.55cm] {50\% dropout};
\end{tikzpicture}
\end{preview}
\end{document}

0 comments on commit d436e1f

Please sign in to comment.