4

The right end of the braces is compiling weird in every program that I tried to use. Can someone help me, please?

\documentclass[tikz,border=5]{standalone}
\usepackage{tikz}
\usepackage[brazilian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetikzlibrary{decorations.pathreplacing}

\def\layersep{2cm}

\begin{document}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,thin,draw=black!80,minimum size=20pt,inner sep=0pt]
\tikzstyle{annot} = [text width=2cm, text centered]
\tikzstyle{input}=[circle,,fill=none,minimum size=20pt,inner sep=0pt]

% 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[neuron] (I-\name) at (0,-\y) {$x_{\name}$};

% Draw the hidden layer nodes
\foreach \name / \y in {1,...,5}
    \path[yshift=0.5cm]
        node[neuron] (H1-\name) at (\layersep,-\y cm) {};


    % Draw the hidden layer nodes
\foreach \name / \y in {1,...,2}
    \path[yshift=0.5cm]
        node[neuron] (H2-\name) at (2*\layersep,-\y cm - 1.5 cm) {};

% Draw the second hidden layer nodes
\foreach \name / \y in {1,...,6}
    \path[yshift=0.5cm]
        node[neuron] (H3-\name) at (3*\layersep,-\y cm + 0.5 cm){};

% Draw the output layer node
\foreach \name / \y in {1,...,3}
    \path[yshift=0.5cm]
        node[neuron] (O-\name) at (4*\layersep,-\y cm - 1cm){};

    \foreach \name / \y in {1,...,3}
        \path[yshift=0.5cm]
    node[input] (Oy-\name) at (4.5*\layersep, -\y cm - 1cm) {$y_{\y}$};

% 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 (H1-\dest);

\foreach \source in {1,...,5}
    \foreach \dest in {1,...,2}
        \path (H1-\source) edge (H2-\dest);

\foreach \source in {1,...,2}
    \foreach \dest in {1,...,6}
        \path (H2-\source) edge (H3-\dest);

    \foreach \source in {1,...,6}
    \foreach \dest in {1,...,3}
        \path (H3-\source) edge (O-\dest);

    \foreach \source in {1,...,3}
            \path (O-\source) edge (Oy-\source);

    \draw[decoration=brace, decorate] (H1-1.north west |- 0,0.5) -- (H3-1.north east |- 0,0.5)
                            node (hiddenlayer) [midway, above=1pt] {\footnotesize{Hidden Layers}};


\end{tikzpicture}

\end{document}

enter image description here

  • 1
    add - so it should be \draw[decoration=brace, decorate,-] – CroCo Oct 21 '15 at 1:24
5

Since you are using -> in all lines, in here

\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]

You need to add - in this line so that -> in the default line is not used, therefore, the correct line is

\draw[decoration=brace, decorate,-] ...

  • @gondimribeiro, if it solves your problem, you can accept it an answer. Cheers. – CroCo Oct 21 '15 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.