[Tex/LaTex] Draw autoencoder structure using TikZ

tikz-pgf

I am trying to draw a denoising autoencoder using TikZ. I do not need all the connections between different layers. Something simple as a block representation per layer is enough. I would ideally like to have two big blocks, that have encoder and decoder layers. So far I have only gotten so far..

    \begin{tikzpicture}
    [title/.style={font=\fontsize{18}{18}\color{black!45}},
    En/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=9em},
    De/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=9em}]
    % Place nodes
    \node [En, outer sep=8pt, align=center] (s1) at (5,8.3) {In};
    \node [En, outer sep=8pt, align=center] (s2) at (7.65,8.3) {E1};
    \node [En, outer sep=8pt] (s3) at (10.3,8.3) {E2};
    \node [draw=black!50, fit={(s1) (s2) (s3)}] (back) {};

    \node [De, outer sep=8pt, align=center] (s4) at (12.95,8.3) {D1};
    \node [De, outer sep=8pt, align=center] (s5) at (15.6,8.3) {D5};
    \node [De, outer sep=8pt] (s6) at (18.3,8.3) {Ot};
    \node [draw=black!50, fit={(s4) (s5) (s6)}] (back) {};
\end{tikzpicture}

Which gives me
enter image description here

What I want
enter image description here

Apologies, I did this in MS paint.

Best Answer

Just for fun:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shapes.misc, fit}

\begin{document}
\begin{tikzpicture}[
    circ/.style={circle, minimum size=1cm, 
        draw=black!70, fill=red!80!black},
    cross/.style={circle, minimum size=1cm,
        draw=black!70, fill=white,
        path picture={\node[cross out, draw, ultra thick, red, minimum size=5mm]{};}},
    H/.style={rounded corners, fill=black!20, row sep=2mm},
    column/.pic={
        \matrix (#1) [H, label={[name=l#1]#1}]
        {\node[circ]{};\\
        \node[cross]{};\\
        \node[circ]{};\\
        \node[cross]{};\\
        \node[cross]{};\\
        \node[circ]{};\\};
        }
    ]

    \path (0,0) pic{column=Input};
    \path (1.5,0) pic{column=H1};
    \path (3,0) pic{column=H2};

    \node[fit=(Input) (lInput) (H2), draw, label=Encoder]{};

    \begin{scope}[xshift=5cm]
    \path (0,0) pic{column=H3};
    \path (1.5,0) pic{column=H4};
    \path (3,0) pic{column=Output};

    \node[fit=(H3) (lOutput) (Output), draw, label=Decoder]{};
    \end{scope}

\end{tikzpicture}
\end{document}

enter image description here

Related Question