This is second attempt to reproduce the diagram below. 
It was recommended that I use fit library, I tried it out and I got to the point below:
\documentclass[tikz]{standalone}
%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary {fit}
\usepackage{xcolor}
\definecolor{darkblue}{HTML}{1f4e79}
\definecolor{lightblue}{HTML}{00b0f0}
\definecolor{salmon}{HTML}{ff9c6b}
\usetikzlibrary{backgrounds,calc,shadings,shapes.arrows,arrows,shapes.symbols,shadows,positioning,decorations.markings,backgrounds,arrows.meta}
% Define parallelepiped shape:
\makeatletter
\pgfkeys{/pgf/.cd,
parallelepiped offset x/.initial=2mm,
parallelepiped offset y/.initial=2mm
}
\pgfdeclareshape{parallelepiped}
{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid west}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{south east}
\backgroundpath{
% store lower right in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
\pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/parallelepiped
offset x}}
\pgfmathsetlength\pgfutil@tempdimb{\pgfkeysvalueof{/pgf/parallelepiped
offset y}}
\def\ppd@offset{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}}
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
\pgfpathclose
\pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
\pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@ya}}{\ppd@offset}}
\pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@yb}}{\ppd@offset}}
\pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xa}{\pgf@yb}}{\ppd@offset}}
\pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
\pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@yb}}{\ppd@offset}}
}
}
\makeatother
\tikzset{
% Dark blue blocks
block/.style={
parallelepiped,fill=white, draw,
minimum width=0.2cm,
minimum height=3.2cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=darkblue,bottom color=darkblue]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% many
block2/.style={
parallelepiped,fill=white, draw,
minimum width=0.3cm,
minimum height=2.7cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=darkblue,bottom color=darkblue]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
%last
block3/.style={
parallelepiped,fill=white, draw,
minimum width=0.3cm,
minimum height=1.7cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=darkblue,bottom color=darkblue]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% Orange-ish blocks
conv/.style={
parallelepiped,fill=white, draw,
minimum width=0.8cm,
minimum height=1.0cm,
parallelepiped offset x=0.1cm,
parallelepiped offset y=0.1cm,
path picture={
\draw[top color=salmon,bottom color=salmon]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% Orange-ish blocks
conv2/.style={
parallelepiped,fill=white, draw,
minimum width=0.4cm,
minimum height=1.0cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=salmon,bottom color=salmon]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% Taller Light blue blocks:
plate/.style={
parallelepiped,fill=white, draw,
minimum width=0.09cm,
minimum height=3.1cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=lightblue,bottom color=lightblue]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% style
% Taller Light blue blocks:
plate2/.style={
parallelepiped,fill=white, draw,
minimum width=0.1cm,
minimum height=2.5cm,
parallelepiped offset x=0.5cm,
parallelepiped offset y=0.5cm,
path picture={
\draw[top color=lightblue,bottom color=lightblue]
(path picture bounding box.south west) rectangle
(path picture bounding box.north east);
},
text=white,
},
% Arrows between blocks:
link/.style={
color=white,
line width=1mm,
},
link2/.style={
color=lightblue,
line width=1mm,
},
}
\begin{document}
\begin{tikzpicture}
% The order of blocks matters since some are partially hidden behind subsequent blocks.
\nodeconv {\rotatebox{90}{Train Data}};
\nodeconv, above=0.9cm of conv1
{\rotatebox{90}{Generator}};
\nodeconv, below=0.9cm of conv1
{\rotatebox{90}{Ref. Data }};
% \nodeplate,right=4.9cm of conv1{};
% yshift to align the bottom of that blocks with the previous taller block.
\nodeblock,right=3.cm of conv1,yshift=0.001cm{\rotatebox{90}{1}};
\draw [-triangle 60,link2] ([xshift=0.1cm,yshift=0.2cm]conv1.east) -- ([xshift=0.0cm,yshift=0.2cm]resblock1.west);
\nodeblock,right=0.1cm of resblock1{\rotatebox{90}{1}};
% \nodeblock,above=0.1cm of resblock1{\rotatebox{90}{2}};
% \nodeblock,above=0.1cm of resblock2{\rotatebox{90}{3}};
% \nodeblock,right=0.2cm of resblock1{\rotatebox{90}{(X4)}};
% \nodeblock,above=0.1cm of x1{\rotatebox{90}{Dense Layer}};
% \nodeblock,above=0.1cm of x2{\rotatebox{90}{(X2)}};
\nodeplate,right=0.2cm of resblock2{\rotatebox{90}{BatchNorm}};
\nodeblock2,right=0.2cm of plate2{\rotatebox{90}{ResBlock4}};
\nodeblock2,right=0.1cm of resblock4{\rotatebox{90}{ResBlock6}};
\nodeplate2,right=0.2cm of resblock6{\rotatebox{90}{\small BatchNorm}};;
\nodeblock3,right=0.3cm of plate3{\rotatebox{90}{ \small
ResBlock5}};
\nodeconv2,right=0.2cm of resblock5{\rotatebox{90}{Conv}};
\nodedraw=red,very thick, fit=(resblock1) (resblock1) (plate2) (resblock4) (resblock4) (plate3) (resblock5) (last) {};
% \draw [-,link] ([xshift=0.2cm,yshift=0.2cm]last.east) -- ([yshift=0.2cm]last.west);
% \node[below] at (fit.south) {box};
\node[above] at (fitter.south) {box};
\node[below] at (fitter.north) {box};
\draw [link] ([xshift=1.cm,yshift=0.2cm]last.east) -- ([xshift=1.5cm,yshift=0.2cm]last.east) ;
\draw [-triangle 60,link2] ([xshift=0.1cm,yshift=0.2cm]fitter.west) -- ([xshift=0.0cm,yshift=0.2cm]conv3.east);
\draw [-triangle 60,link2] ([xshift=0.0cm,yshift=0.0cm]conv3.south) -- ([xshift=0.0cm,yshift=0.0cm]conv1.north);
\draw [-triangle 60,link2] ([xshift=0.0cm,yshift=0.0cm]conv2.north) -- ([xshift=0.0cm,yshift=0.0cm]conv1.south);
\end{tikzpicture}
\end{document}
This was inspired by the solution here Producing stacked 3D blocks using TikZ and the recommendation from the solution here Flow diagam and 3D diagrams tikz .
The output I have now is as below:
I want to :
- add the arrows properly and format the fit the rectangle appropriately
- add the text accordingly.
Thanks


path pictureoption and not justfillthe shapes? You can tryright=0.1cm of resblock1.south east, anchor=south westto align the blocks at the bottom. – Jasper Habicht Apr 06 '23 at 06:20fitproblem, you can always either use anchors (if they exist) orxshift/yshiftas options to the coordinates you want to fit (like([yshift=1cm]resblock1)for example), to correctly fit the node. Note that you need to place the argument to thefitoption inside curly braces ({}) if you want to use square brackets ([]) inside. – Jasper Habicht Apr 06 '23 at 06:25fitlibrary only takes the main compass anchors (north, east, south and west) in consideration when you just give it a node name. The shape's definition doesn't change any of these anchors from the original rectangle which is why the 3d-ness of that shape is basically invisible forfit. There's room for improvement in that shape's definition. As a workaround you could have those cuboids create coordinates automatically on-the-fly and use them infitto avoid having to use[yshift=1cm]like @JasperHabicht suggested. – Qrrbrbirlbel Apr 06 '23 at 08:42yshiftshould probably only be used together with coordinates in the context offit. I just suggested it as another option which I though might be easier for the OP then to redefine the shape. – Jasper Habicht Apr 06 '23 at 09:29circuitikz? I do not see where I can help here... – Rmano Apr 06 '23 at 12:11