4

I have a problem which I can not solve. I'm quite new to the world of LaTeX and I don't know much about macros. Heres my problem: I draw a Neural Network using the Neuralnetwork package.

I have an input layer, two hidden layer and an output layer. Except the ouput layer I have bias neurons in the layers. I would like to label the bias neurons like b_0 (at input layer) , b_1 and b_2 (at first/second hidden layer). I also would like to label the neurons of the hidden layer from h_1 to h4 (first hidden layer) and h4 to h7 (second hidden layer). I don't know how to do that. Heres my current code:

\begin{neuralnetwork}[height=5]
  \newcommand{\nodetextx}[2]{$x_#2$}
  \newcommand{\nodetextz}[2]{$z_#2$}
  \inputlayer[count=2, title={Input}, text=\nodetextx]
  \hiddenlayer[count=4, title={Hidden 1}]
  \linklayers
  \hiddenlayer[count=3, title={Hidden  2}]
  \linklayers
  \outputlayer[count=2, title={Output}, text=\nodetextz] 
  \linklayers
\end{neuralnetwork}

This generates the following graphic: enter image description here

I would like to have it like this:

enter image description here

I appreciate any help. :) Thank you very much Kind regards

1
  • The manual is online, but theres not stated how I do that. I also wrote a mail to the guy who created the package, but he hasn't used LaTeX for several years, he wasn't able to help me. I tried to solve my problem for two days and decided to go on my work. If there is no one here who can help, I will just use the drawing I have, but I will be highly unsatisfied. :/
    – AlcuPala
    Jun 16, 2016 at 13:17

1 Answer 1

1

Here is an horrible solution:

\documentclass{standalone}
\usepackage{neuralnetwork}
\usepackage{ifthen}
\begin{document}
\begin{neuralnetwork}[height=5]
  \newcommand{\nodetextx}[2]{\ifthenelse{\equal{#2}{0}}{$b_0$}{$x_{#2}$}}
  \newcommand{\nodetextz}[2]{$z_{#2}$}
  \newcommand{\nodetexth}[2]{\ifthenelse{\equal{#2}{0}}{$b_1$}{$h_{#2}$}}
  \newcommand{\nodetexthi}[2]{%
      \pgfmathsetmacro\num{int(#2+4)}%
      \ifthenelse{\equal{#2}{0}}{$b_2$}{$h_{\num}$}}
  \inputlayer[count=2, title={Input}, text=\nodetextx]
  \hiddenlayer[count=4, title={Hidden 1}, text=\nodetexth]
  \linklayers
  \hiddenlayer[count=3, title={Hidden  2}, text=\nodetexthi]
  \linklayers
  \outputlayer[count=2, title={Output}, text=\nodetextz] 
  \linklayers
\end{neuralnetwork}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .