Problema de posicionamiento de las etiquetas Tikz Arrow

Problema de posicionamiento de las etiquetas Tikz Arrow

Tengo la siguiente imagen tikz: Imagen de Tikz que muestra el desarrollo de una red neuronal recurrente a lo largo del tiempo.

\usepackage{tikz}
\usetikzlibrary{positioning, chains}
\begin{document}
\begin{tikzpicture}[
item/.style={circle,draw,thick,align=center, minimum size=1.2cm},
hidden/.style={item,on chain,join}]

 \begin{scope}[start chain=going right,nodes=hidden,every
 join/.style={-latex,very thick},local bounding box=chain]
 \draw node (A0) {$h_0$} node (A1) {$h_1$} node (A2) {$h_2$} node[xshift=2em] (At)
 {$h_t$};
 \end{scope}
 \node[left=1em of chain,scale=2] (eq) {$=$};
 \node[left=2em of eq,item] (AL) {$h$};
 \path (AL.west) ++ (-1em,2em) coordinate (aux);
 \draw[very thick,-latex,rounded corners] (AL.east) -| ++ (1em,2em) -- (aux)
 |- (AL.west) node[midway, left] {$U$};
 \foreach \X in {0,1,2,t}
 {\draw[very thick,-latex] (A\X.north) -- ++ (0,2em) node[midway, right] {$V$}
 node[above,item,fill=gray!10] (h\X) {$\hat{y}_\X$};
 \draw[very thick,latex-] (A\X.south) -- ++ (0,-2em) node[midway, right] {$W$}
 node[below,item,fill=gray!10] (x\X) {$x_\X$};
 \path (A\X.east) -- (A\X -| At.west) node[midway, above] {$U$};
}
 
 \draw[white,line width=0.8ex] (AL.north) -- ++ (0,1.9em);
 \draw[very thick,-latex] (AL.north) -- ++ (0,2em) node[midway, right] {$V$}
 node[above,item,fill=gray!10] {$\hat{y}_t$};
 \draw[very thick,latex-] (AL.south) -- ++ (0,-2em) node[midway, right] {$W$}
 node[below,item,fill=gray!10] {$x_t$};
 \path (x2) -- (xt) node[midway,scale=2,font=\bfseries] {\dots};
\end{tikzpicture}
\end{document}

No puedo colocarlo Ude manera que se alinee con sus respectivas flechas. ¿Alguien puede indicarme la dirección correcta?

Respuesta1

Para el primero U, el código -- (aux) --++(0em,-2em) node[midway, left] {$U$} -- (AL.west);se puede usar en la ruta para colocar la Umitad del segmento de línea a la izquierda.

Para los demás U, se puede utilizar el siguiente código para colocar cada uno Upor separado.

\path (A0.east) -- (A1.west) node[midway, above] {$U$};
\path (A1.east) -- (A2.west) node[midway, above] {$U$};
\path (A2.east) -- (At.west) node[midway, above] {$U$};

\path (A\X.east) -- (A\X -| At.west) node[midway, above] {$U$};Entonces se puede quitar la línea .

Respuesta2

Un código un poquito más corto y (mucho más) claro con etiquetas de borde de ubicación correcta. En comparación con el código OP MWE, a continuación se utilizan bibliotecas adicionales arrows.meta(para flechas más bonitas), ext.paths.orth(para tipos de flechas // ortogonales r-lr) y quotespara (etiquetas de borde):

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                ext.paths.ortho,    % defined in the tikz-ext package
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
  start chain = going right,
   arr/.style = {-{Straight Barb[scale=0.8]}, semithick},
  item/.style = {circle, draw, thick, fill=gray!30, minimum size=11mm},
hidden/.style = {item, fill=none,
                 on chain, join=by arr},
                        ]
% from right to left
    \foreach \i in {0,1,2,t}
{
\node (A\i) [hidden] {$h_\i$};
\node (B\i) [item, above=of A\i]  {$\hat{y}_\i$};
\node (C\i) [item, below=of A\i]  {$x_\i$};
\draw[arr]  (A\i) to["$V$" '] (B\i);
\draw[arr]  (A\i) to["$W$"] (C\i);
}
\path   (A0) to ["$V$"] (A1) to ["$V$"] (A2) to ["$V$"] (At);
\draw[thick,densely dashed, white, shorten >=2mm, shorten <=2mm]   (A2) to (At);
% equals sign 
\node (eq) [left=1em of A0, scale=2] {$=$};
% general/common symbol
\node (AL) [item, fill=none, left=2em of eq,] {$h$};
\node (Y) [item, above=of AL]  {$\hat{y}_t$};
\node (X) [item, below=of AL]  {$x_t$};
\draw[arr]  (AL) to["$V$" '] (Y);
\draw[arr]  (AL) to["$W$"]   (X);
\draw[arr, rounded corners]
    (AL.east) -| ++ (1em,2em) r-lr (AL) node[midway, left] {$U$};
    \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada