made it use figure

This commit is contained in:
Robin Clark 2010-11-30 17:12:58 +00:00
parent 0c69424be0
commit e0cdfe8ce3

View File

@ -1,59 +1,62 @@
\documentclass{article} \documentclass{article}
\usepackage{tikz} \usepackage{tikz}
\usepackage{verbatim} \usepackage{verbatim}
\begin{comment} \begin{comment}
:Title: Neural network :Title: Neural network
:Tags: Foreach :Tags: Foreach
The ``\foreach`` command is very useful for quickly creating structured graphics The ``\foreach`` command is very useful for quickly creating structured graphics
like this neural network diagram. like this neural network diagram.
\end{comment} \end{comment}
\begin{document} \begin{document}
\pagestyle{empty} \pagestyle{empty}
\def\layersep{2.5cm} \def\layersep{2.5cm}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] \begin{figure}
\tikzstyle{every pin edge}=[<-,shorten <=1pt] \begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt] \tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{input neuron}=[neuron, fill=green!50]; \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{output neuron}=[neuron, fill=red!50]; \tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50]; \tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{annot} = [text width=4em, text centered] \tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
\foreach \name / \y in {1,...,4} % Draw the input layer nodes
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4} \foreach \name / \y in {1,...,4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {}; % This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,5} % Draw the hidden layer nodes
\path[yshift=0.5cm] \foreach \name / \y in {1,...,5}
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {}; \path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
% Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {}; % Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {};
% Connect every node in the input layer with every node in the
% hidden layer. % Connect every node in the input layer with every node in the
\foreach \source in {1,...,4} % hidden layer.
\foreach \dest in {1,...,5} \foreach \source in {1,...,4}
\path (I-\source) edge (H-\dest); \foreach \dest in {1,...,5}
\path (I-\source) edge (H-\dest);
% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,5} % Connect every node in the hidden layer with the output layer
\path (H-\source) edge (O); \foreach \source in {1,...,5}
\path (H-\source) edge (O);
% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; % Annotate the layers
\node[annot,left of=hl] {Input layer}; \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer};
\node[annot,right of=hl] {Output layer}; \node[annot,left of=hl] {Input layer};
\node[annot,right of=hl] {Output layer};
\end{tikzpicture}
% End of code
\caption{bollocks} \caption{bollocks}
\end{tikzpicture} \end{figure}
% End of code
\end{document} \end{document}