tizk を使用して単一のニューラル ユニットを描画する

tizk を使用して単一のニューラル ユニットを描画する

次のような絵を描きたいと思います。 ここに画像の説明を入力してください

以下は私の LaTeX コードです。

  \documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,calc}

\tikzset{
  arro/.style={
    ->,
    >=latex
  },
  bloque/.style={
    draw,
    minimum height=1cm,
    minimum width=0.5cm
  }  
}

\begin{document}

\begin{tikzpicture}[]
\node[]
  (input)
  {Input};
\node[below=of input,label={left:$x_{1}$}]
  (inputi)
  {};
\node[below=of inputi,label={left:$x_{2}$}]
  (inputii)
  {};
\coordinate[below=of inputii] (aux);  
\node[below=of aux,label={left:$x_{3}$}]
  (inputiii)
  {};
\node[below=of inputiii,label={left:$+1$}]
  (inputiv)
  {};

\node[right=of input]
  (proje)
  {Projection};
\node[circle,label={above:\textsc{sum}}]
  at (proje|-aux)
  (projei)
  {};

\node[right=of proje]
  (out)
  {Output};
\node[label={right:$h_{w,b}(x)$}]
  at (out|-aux)
  (outi)
  {};

\foreach \Valor in {i,ii,iii,iv}
{
  \draw[arro] (input\Valor) -- (projei);
}  
\draw[arro] (projei) -- (outi);
\end{tikzpicture}

\end{document}

私が得たものは次のとおりです: ここに画像の説明を入力してください

次のコードを追加してみます:\begin{tikzpicture}[every node/.style={draw=black,circle}]

そしてこれを取得します: ここに画像の説明を入力してください

誰か助けてくれませんか? ありがとう!

答え1

質問にほぼ答えていますが、すべてのノードのアウトラインを描画するのではなく、1つのノードだけを描画したいとします。そのため、drawその1つのノードにオプションとして追加する必要があります。サイズを大きくするには、たとえば以下を追加します。minimum size=1cm、色を変更する場合は色名を追加することもできます。

以下のコードでは、コメントで示されている 1 行を追加しました。

ここに画像の説明を入力してください

  \documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,calc}

\tikzset{
  arro/.style={
    ->,
    >=latex
  },
  bloque/.style={
    draw,
    minimum height=1cm,
    minimum width=0.5cm
  }  
}

\begin{document}

\begin{tikzpicture}[]
\node[]
  (input)
  {Input};
\node[below=of input,label={left:$x_{1}$}]
  (inputi)
  {};
\node[below=of inputi,label={left:$x_{2}$}]
  (inputii)
  {};
\coordinate[below=of inputii] (aux);  
\node[below=of aux,label={left:$x_{3}$}]
  (inputiii)
  {};
\node[below=of inputiii,label={left:$+1$}]
  (inputiv)
  {};

\node[right=of input]
  (proje)
  {Projection};
\node[circle,
   draw,minimum size=1cm,orange, %% <-- these are added
   label={above:\textsc{sum}}]
  at (proje|-aux)
  (projei)
  {};

\node[right=of proje]
  (out)
  {Output};
\node[label={right:$h_{w,b}(x)$}]
  at (out|-aux)
  (outi)
  {};

\foreach \Valor in {i,ii,iii,iv}
{
  \draw[arro] (input\Valor) -- (projei);
}  
\draw[arro] (projei) -- (outi);
\end{tikzpicture}

\end{document}

labelまた、左側の入力ノードと出力ノードにはを使用しないことをお勧めします。その他の小さな変更点がいくつかあります。

ここに画像の説明を入力してください

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,calc}

\tikzset{
  arro/.style={
    ->,
    >=latex
  },
  bloque/.style={
    draw,
    minimum height=1cm,
    minimum width=0.5cm
  }  
}

\begin{document}

\begin{tikzpicture}[node distance=0.5cm and 1cm] % first value vertical distance, second horizontal
\node
  (input)
  {Input};
\node[below=of input]
  (inputi)
  {$x_{1}$};
\node[below=of inputi]
  (inputii)
  {$x_{2}$};
\coordinate[below=of inputii] (aux);  
\node[below=of aux]
  (inputiii)
  {$x_{3}$};
\node[below=of inputiii]
  (inputiv)
  {$+1$};

\node[right=of input]
  (proje)
  {Projection};
\node[circle,
   draw,minimum size=1cm,orange, 
   label={above:\textsc{sum}}]
  at (proje|-aux)
  (projei)
  {};

\node[right=of proje]
  (out)
  {Output};
\node
  at (out|-aux)
  (outi)
  {$h_{w,b}(x)$};

\foreach \Valor in {i,ii,iii,iv}
{
  \draw[arro] (input\Valor) -- (projei);
}  
\draw[arro] (projei) -- (outi);
\end{tikzpicture}
\end{document}

答え2

もう少し複雑で簡潔な代替案 :-) :

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 4mm and 16mm,
  start chain = going below,
  arro/.style = {-Latex},
bloque/.style = {text width=4ex, inner sep=1pt, align=right, on chain},
                        ]
% inputs
\foreach \i [count=\j] in {1, 2, 3, +1}
    \node[bloque] (in-\j) {$x_{\i}$};
% output
\node (out) [circle, draw=orange, minimum size=6mm,
      label=\textsc{sum},
      right=of $(in-2)!0.5!(in-3)$]  {};
% conections
\foreach \i in {1,...,4}
    \draw[arro] (in-\i) -- (out);
% output
\coordinate[right=of out] (output);
\draw[arro] (out) -- (output) node[right]   {$h_{w,b}(x)$};
% layer labels
\node[above=of in-1.center]     {Input};
\node[above=of in-1 -| out]     {Projection};
\node[above=of in-1 -| output]  {Ouput};
    \end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報