برای تغییر مکان شکل پایینی آن را در یک scope قرار داده و به کمک xshift و yshift جابجا میکنیم. به منظور یکسان کردن شکل ظاهری هم از styleهایی که تعریف کردهاید استفاده میکنیم. کافی است thick
را به استایل neuron اضافه کنید. همچنین [-stealth, thick]
را به تمام pathها اضافه کنید.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\def\nodesep{1cm} % vertical distance between nodes
\def\layersep{1cm} % horizontal distance between nodes
% boundary
\def\hsep{0}
\def\ilsize{5} % number of input layer nodes
\def\hlsize{5} % number of hidden layer nodes
\def\olsize{2} % number of output layer nodes
\def\rootlrp{6}
\def\neuronsize{3mm}
\tikzset{>=latex}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
node/.style={circle, draw, thick},
shorten >=0pt, ->, draw=black!100, node distance=\layersep,
every pin edge/.style={<-,shorten <=1pt},
neuron/.style={circle, draw, thick, fill=black!100, minimum size=\neuronsize,inner sep=0pt},
input neuron/.style={neuron, fill=black!0},
hidden neuron/.style={neuron, fill=black!0},
output neuron/.style={neuron, fill=black!0}
]
\begin{scope}
\foreach \y in {1,...,5}{
\node[node] (i\y) at (0,\nodesep*\y) {};
\node[node, right=\layersep of i\y] (h1\y) {};
\node[node, right=\layersep of h1\y] (h2\y) {};
}
\node[node, right=\layersep of h22] (o1) {};
\node[node, right=\layersep of h24] (o2) {};
\foreach \source in {1,...,5}
\foreach \dest in {1,...,5}{
\path[-stealth, thick] (i\source) edge (h1\dest);
\path[-stealth, thick] (h1\source) edge (h2\dest);
}
\foreach \source in {1,...,5}
\foreach \dest in {1,2}
\draw[-stealth, thick] (h2\source) -- (o\dest);
\draw[-stealth, thick] (5,3*\nodesep) -- node[above,font=\Large\bfseries] {dropout} (8, 3*\nodesep);
\end{scope}
\begin{scope}[xshift=9cm,yshift=6cm]
% Boundary
%*****************************************
%*****************************************
%*****************************************
\pgfmathsetmacro{\iyshift}{0.5*\ilsize-0.5*\hlsize}
\pgfmathsetmacro{\oyshift}{0.5*\olsize-0.5*\hlsize}
%%%%%%%%%%%%
% DRAW NODES
%%%%%%%%%%%%
% Draw the input layer nodes
\foreach \name / \y in {1,...,\ilsize}
\node[input neuron] (In-\name) at (0.0cm+\hsep,-\y cm+\iyshift cm) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,\hlsize}
\node[hidden neuron] (H0-\name) at (1.5cm+\hsep,-\y cm) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,\hlsize}
\node[hidden neuron] (H1-\name) at (3.0cm+\hsep,-\y cm) {};
% Draw the output layer nodes
\foreach \name / \y in {1,...,\olsize}
\node[hidden neuron] (Out-\name) at (4.5cm+\hsep,-\y cm+\oyshift cm) {};
%%%%%%%%%%%%%%%%%%
% DRAW CONNECTIONS
%%%%%%%%%%%%%%%%%%
\pgfmathsetmacro{\cutoff}{0.5}
% Connect every node in the input layer with every node in the hidden layer.
\foreach \source in {1,...,\ilsize}
{\foreach \dest in {1,...,\hlsize}
{\pgfmathparse{int(sign(rnd-\cutoff))}
\ifnum\pgfmathresult=1
\path[-stealth, thick] (In-\source) edge (H0-\dest);
\fi}}
\pgfmathsetmacro{\cutoff}{0.3}
% Connect first with second hidden layer
\foreach \source in {1,...,\hlsize}
{\foreach \dest in {1,...,\hlsize}
{\pgfmathparse{int(sign(rnd-\cutoff))}
\ifnum\pgfmathresult=1
\path[-stealth, thick] (H0-\source) edge (H1-\dest);
\fi}}
\pgfmathsetmacro{\cutoff}{0.7}
% Connect every node from the last hidden layer with the output layer
\foreach \source in {1,...,\hlsize}
{\foreach \dest in {1,...,\olsize}
{\pgfmathparse{int(sign(rnd-\cutoff))}
\ifnum\pgfmathresult=1
\path[-stealth, thick] (H1-\source) edge (Out-\dest);
\fi}}
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}
نتیجه