TikZ 다이어그램의 내용 복제 및 미러링

TikZ 다이어그램의 내용 복제 및 미러링

TikZ에서 만든 다음 다이어그램이 있습니다.

여기에 이미지 설명을 입력하세요

이에 대한 코드는 다음과 같습니다.

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning, fit, arrows.meta}

\begin{document}

\begin{tikzpicture}[
    prod/.style={circle, draw, inner sep=0pt, fill=black!5, black!20},
    ct/.style={circle, draw, inner sep=5pt, ultra thick, minimum width=10mm, fill=black!5, black!20},
    ft/.style={circle, draw, minimum width=8mm, inner sep=1pt, fill=black!5, black!20},
    filter/.style={circle, draw, minimum width=7mm, inner sep=1pt, fill=black!5, black!20},
    mylabel/.style={font=\scriptsize\sffamily},
    >=LaTeX
    ]

\node[ct, label={[mylabel, black!20]Memory cell}, fill=black!5] (ct) {};
\node[filter, right=of ct, fill=black!5] (int1) {$f_g$};
\node[prod, right=of int1, fill=black!5] (x1) {$\times$}; 
\node[right=of x1] (ht) {$h_t$};
\node[prod, left=of ct, fill=black!5] (x2) {$\times$}; 
\node[filter, left=of x2, fill=black!5] (int2) {$f_h$};
\node[prod, below=5mm of ct, fill=black!5] (x3) {$\times$}; 
\node[ft, below=5mm of x3, label={[mylabel, black!20]right:Forget gate}, fill=black!5] (ft) {$f_t$};
\node[ft, above=of x2, label={[mylabel, black!20]left:Input gate}, fill=black!5] (it) {$f_t$};
\node[ft, above=of x1, label={[mylabel, black!20]left:Output gate}, fill=black!5] (ot) {$f_t$};

\foreach \i/\j in {int2/x2, x2/ct, ct/int1, int1/x1, x1/ht, it/x2, ct/it, ct/ot, ot/x1, ft/x3}
    \draw[->, black!20] (\i)--(\j);

\draw[->, black!20] (ct) to[bend right=45] (ft);

\draw[->, black!20] (ct) to[bend right=30] (x3);
\draw[->, black!20] (x3) to[bend right=30] (ct);

\node[fit=(int2) (it) (ot) (ft), draw, inner sep=0pt] (fit) {};

\draw[<-] (fit.west|-int2) coordinate (aux)--++(180:7mm) node[left]{$x_t$};
\draw[<-, black!20] ([yshift=1mm]aux)--++(135:7mm);
\draw[<-, black!20] ([yshift=-1mm]aux)--++(-135:7mm);

\draw[<-] (fit.north-|it) coordinate (aux)--++(90:7mm) node[above]{$x_t$};
\draw[<-, black!20] ([xshift=1mm]aux)--++(45:7mm);
\draw[<-, black!20] ([xshift=-1mm]aux)--++(135:7mm);

\draw[<-] (fit.north-|ot) coordinate (aux)--++(90:7mm) node[above]{$x_t$};
\draw[<-, black!20] ([xshift=1mm]aux)--++(45:7mm);
\draw[<-, black!20] ([xshift=-1mm]aux)--++(135:7mm);

\draw[<-] (fit.south-|ft) coordinate (aux)--++(-90:7mm) node[below]{$x_t$};
\draw[<-, black!20] ([xshift=1mm]aux)--++(-45:7mm);
\draw[<-, black!20] ([xshift=-1mm]aux)--++(-135:7mm);

\end{tikzpicture}


\end{document}

이제 아래 그림과 같이 모든 것을 "미러링"하려고 합니다. 이것이 가능한가? (거울에 비친 글자는 신경쓰지 마세요. 저는 그 글자가 거울에 비춰지는 것을 원하지 않습니다. 단지 상자 안의 원과 화살표의 구조만 있을 뿐입니다).

여기에 이미지 설명을 입력하세요

우선 첫 번째 다이어그램 아래에 표시되는 두 번째 다이어그램을 만드는 데에도 어려움을 겪고 있습니다. 외부 for 루프를 사용해 보았지만 전혀 작동하지 않았습니다.

편집: 기호 1은 아래에 \Spy를 사용하여 범위의 복사본을 만드는 훌륭한 답변을 제공했기 때문에 질문을 구체화하고 두 블록 사이에 화살표를 그릴 수 있는 것을 선호한다고 덧붙이고 싶습니다(예: 내 손으로 그린 ​​그림에 빨간색으로 표시됨). 스파이가 만든 복사본이 있을 때 이 작업을 수행하는 방법에 대한 정보를 찾으려고 했지만 아무 것도 찾을 수 없습니다. 어쩌면 불가능할까요?

답변1

다음을 통해 범위의 무료 사본을 얻을 수 있습니다.\spy

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning, fit, arrows.meta,spy}

\begin{document}
    \begin{tikzpicture}[
                prod/.style={circle, draw, inner sep=0pt, fill=black!5, black!20},
                ct/.style={circle, draw, inner sep=5pt, ultra thick, minimum width=10mm, fill=black!5, black!20},
                ft/.style={circle, draw, minimum width=8mm, inner sep=1pt, fill=black!5, black!20},
                filter/.style={circle, draw, minimum width=7mm, inner sep=1pt, fill=black!5, black!20},
                mylabel/.style={font=\scriptsize\sffamily},
                >=LaTeX
            ]
        \begin{scope}[spy scope]
            \node[ct, label={[mylabel, black!20]Memory cell}, fill=black!5] (ct) {};
            \node[filter, right=of ct, fill=black!5] (int1) {$f_g$};
            \node[prod, right=of int1, fill=black!5] (x1) {$\times$}; 
            \node[right=of x1] (ht) {$h_t$};
            \node[prod, left=of ct, fill=black!5] (x2) {$\times$}; 
            \node[filter, left=of x2, fill=black!5] (int2) {$f_h$};
            \node[prod, below=5mm of ct, fill=black!5] (x3) {$\times$}; 
            \node[ft, below=5mm of x3, label={[mylabel, black!20]right:Forget gate}, fill=black!5] (ft) {$f_t$};
            \node[ft, above=of x2, label={[mylabel, black!20]left:Input gate}, fill=black!5] (it) {$f_t$};
            \node[ft, above=of x1, label={[mylabel, black!20]left:Output gate}, fill=black!5] (ot) {$f_t$};
            \foreach \i/\j in {int2/x2, x2/ct, ct/int1, int1/x1, x1/ht, it/x2, ct/it, ct/ot, ot/x1, ft/x3}
                \draw[->, black!20] (\i)--(\j);
            \draw[->, black!20] (ct) to[bend right=45] (ft);
            \draw[->, black!20] (ct) to[bend right=30] (x3);
            \draw[->, black!20] (x3) to[bend right=30] (ct);
            \node[fit=(int2) (it) (ot) (ft), draw, inner sep=0pt] (fit) {};
            \draw[<-] (fit.west|-int2) coordinate (aux)--++(180:7mm) node[left]{$x_t$};
            \draw[<-, black!20] ([yshift=1mm]aux)--++(135:7mm);
            \draw[<-, black!20] ([yshift=-1mm]aux)--++(-135:7mm);
            \draw[<-] (fit.north-|it) coordinate (aux)--++(90:7mm) node[above]{$x_t$};
            \draw[<-, black!20] ([xshift=1mm]aux)--++(45:7mm);
            \draw[<-, black!20] ([xshift=-1mm]aux)--++(135:7mm);
            \draw[<-] (fit.north-|ot) coordinate (aux)--++(90:7mm) node[above]{$x_t$};
            \draw[<-, black!20] ([xshift=1mm]aux)--++(45:7mm);
            \draw[<-, black!20] ([xshift=-1mm]aux)--++(135:7mm);
            \draw[<-] (fit.south-|ft) coordinate (aux)--++(-90:7mm) node[below]{$x_t$};
            \draw[<-, black!20] ([xshift=1mm]aux)--++(-45:7mm);
            \draw[<-, black!20] ([xshift=-1mm]aux)--++(-135:7mm);

            \spy [blue, size=10cm]on(0,0)in node[transform shape,yscale=-1]at(0,10);
        \end{scope}
    \end{tikzpicture}
\end{document}

관련 정보