在 Latex 中绘制自动编码器

在 Latex 中绘制自动编码器

我想绘制我所附的图形。我添加了以下代码https://github.com/JamesAllingham/LaTeX-TikZ-Diagrams/blob/master/2019/Neural%20Networks/Autoencoder/main.tex。你能帮我把图改成我附上的那样吗?我试过了,但是当我必须改变 x 的大小时,所有的东西都变了。非常感谢。https://i.stack.imgur.com/C4Czw.jpg

\standaloneconfig{border=1cm} 
\usepackage[utf8]{inputenc}

\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}

\title{Autoencoder}
\author{James Allingham}
\date{August 2019}

\begin{document}
    
\tikzset{arrow/.style={-stealth, thick, draw=gray!80!black}}

\begin{tikzpicture}
%     \draw[help lines](0,-5) grid (10,5);  
     
    \node[fill=blue!20, minimum width=0.5cm, minimum height=3.5cm] (X) at (0,0) {$\mathbf x$};
    
    \draw[fill=purple!20] ([xshift=0.5cm]X.north east) -- ([xshift=2.5cm,yshift=0.5cm]X.east) -- ([xshift=2.5cm,yshift=-0.5cm]X.east) -- ([xshift=0.5cm]X.south east) -- cycle; 
    \node at (1.75,0) {\textsc{Encoder}};
    
    \node[fill=red!20, minimum width=0.5cm, minimum height=1.0cm] (Z) at (3.5cm,0) {$\mathbf z$};
    
    \draw[fill=purple!20] ([xshift=0.5cm]Z.north east) -- ([xshift=2.5cm,yshift=1.25cm]Z.north east) -- ([xshift=2.5cm,yshift=-1.25cm]Z.south east) -- ([xshift=0.5cm]Z.south east) -- cycle;
    \node at (5.25,0) {\textsc{Decoder}};
    
    \node[fill=blue!20, minimum width=0.5cm, minimum height=3.5cm] (Xp) at (7,0) {$\mathbf{\hat{x}}$};
    
    \draw[arrow] (X.east) -- ([xshift=0.5cm]X.east);
    \draw[arrow] ([xshift=-0.5cm]Z.west) -- (Z.west);
    \draw[arrow] (Z.east) -- ([xshift=0.5cm]Z.east);
    \draw[arrow] ([xshift=-0.5cm]Xp.west) -- (Xp.west);
     
\end{tikzpicture}

\end{document}```


  [1]: https://i.stack.imgur.com/ZIhJ3.jpg

答案1

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, positioning, calc}    

\title{Autoencoder}
\author{James Allingham}
\date{August 2019}

\begin{document}
    
    \tikzset{arrow/.style={-stealth, thick, draw=gray!80!black}}
    
    \begin{tikzpicture}\noindent\hspace{-4cm}
        
        \node[minimum width=0.5cm, minimum height=3.5cm] (X) at (0,0) {};
        \draw[fill=purple!20] ([xshift=0.5cm]X.north east)coordinate(aux) -- ([xshift=2.5cm,yshift=0.5cm]X.east)coordinate(aux1) -- ([xshift=2.5cm,yshift=-0.5cm]X.east) -- ([xshift=0.5cm]X.south east) -- cycle; 
        \node at (1.75,0) {\textsc{Encoder}};
        \node[draw,inner sep=4pt,] at ([xshift=-2cm, yshift=2cm]X)(x1){x1};
        \draw[arrow] (x1.south)|-([yshift=-1cm]aux) ;
        \node[inner sep=6pt, draw, below=3cm of x1,](z){z};
        \draw[arrow] (z.north)|-([yshift=-2cm]aux) ;
        \node[draw, minimum width=0.5cm, minimum height=2.0cm, right=8cm  of X](Z)  {z};
        \draw[]([yshift=-1em]aux1)coordinate(aux2)-|(Z.west);
        \draw[]([yshift=-1.8em]aux1)-|(Z.west);
        \node[draw, fill=white, minimum width=1cm, minimum height=0.3cm,]at($(aux2)!0.5!(Z.west)$)(){z};

    \end{tikzpicture}
    
\end{document}

相关内容