From e0cdfe8ce325a74e64794f16266e75360076b787 Mon Sep 17 00:00:00 2001 From: Robin Clark Date: Tue, 30 Nov 2010 17:12:58 +0000 Subject: [PATCH] made it use figure --- latex_examples/neural-network.tex | 119 +++++++++++++++--------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/latex_examples/neural-network.tex b/latex_examples/neural-network.tex index 0fd83c8..9ca088d 100644 --- a/latex_examples/neural-network.tex +++ b/latex_examples/neural-network.tex @@ -1,59 +1,62 @@ -\documentclass{article} - -\usepackage{tikz} -\usepackage{verbatim} - -\begin{comment} -:Title: Neural network -:Tags: Foreach - -The ``\foreach`` command is very useful for quickly creating structured graphics -like this neural network diagram. - -\end{comment} - -\begin{document} -\pagestyle{empty} - -\def\layersep{2.5cm} - -\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] - \tikzstyle{every pin edge}=[<-,shorten <=1pt] - \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt] - \tikzstyle{input neuron}=[neuron, fill=green!50]; - \tikzstyle{output neuron}=[neuron, fill=red!50]; - \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} - % 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} - \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) {}; - - % Connect every node in the input layer with every node in the - % hidden layer. - \foreach \source in {1,...,4} - \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} - \path (H-\source) edge (O); - - % Annotate the layers - \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; - \node[annot,left of=hl] {Input layer}; - \node[annot,right of=hl] {Output layer}; +\documentclass{article} + +\usepackage{tikz} +\usepackage{verbatim} + +\begin{comment} +:Title: Neural network +:Tags: Foreach + +The ``\foreach`` command is very useful for quickly creating structured graphics +like this neural network diagram. + +\end{comment} + +\begin{document} +\pagestyle{empty} + +\def\layersep{2.5cm} + +\begin{figure} +\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] + \tikzstyle{every pin edge}=[<-,shorten <=1pt] + \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt] + \tikzstyle{input neuron}=[neuron, fill=green!50]; + \tikzstyle{output neuron}=[neuron, fill=red!50]; + \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} + % 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} + \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) {}; + + % Connect every node in the input layer with every node in the + % hidden layer. + \foreach \source in {1,...,4} + \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} + \path (H-\source) edge (O); + + % Annotate the layers + \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; + \node[annot,left of=hl] {Input layer}; + \node[annot,right of=hl] {Output layer}; +\end{tikzpicture} +% End of code \caption{bollocks} -\end{tikzpicture} -% End of code -\end{document} - +\end{figure} + +\end{document} +