I'd like to draw a 3D volume of blocks for representing convolutional network (CNN) using TikZ. Below is a picture I'm trying to re-create:
I've been struggling to create this block for days and still not much progress :(. Could the TikZ ninjas here help me with this?
Please note that the horizontal line below the second slab is not needed (it appeared while cropping). Thanks!
Below is what I tried so far (based on the solution of Drawing a CNN with TikZ)
\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{3d,decorations.text,shapes.arrows,positioning,fit,backgrounds}
\tikzset{pics/fake box/.style args={% #1=color, #2=x dimension, #3=y dimension, #4=z dimension
#1 with dimensions #2 and #3 and #4}{
code={
\draw[gray,ultra thin,fill=#1] (0,0,0) coordinate(-front-bottom-left) to
++ (0,#3,0) coordinate(-front-top-right) --++
(#2,0,0) coordinate(-front-top-right) --++ (0,-#3,0)
coordinate(-front-bottom-right) -- cycle;
\draw[gray,ultra thin,fill=#1] (0,#3,0) --++
(0,0,#4) coordinate(-back-top-left) --++ (#2,0,0)
coordinate(-back-top-right) --++ (0,0,-#4) -- cycle;
\draw[gray,ultra thin,fill=#1!80!black] (#2,0,0) --++ (0,0,#4) coordinate(-back-bottom-right)
--++ (0,#3,0) --++ (0,0,-#4) -- cycle;
\path[gray,decorate,decoration={text effects along path,text={CONV}}] (#2/2,{2+(#3-2)/2},0) -- (#2/2,0,0);
}
}}
\tikzset{circle dotted/.style={dash pattern=on .05mm off 2mm,
line cap=round}}
\begin{document}
\begin{tikzpicture}[x={(1,0)},y={(0,1)},z={({cos(60)},{sin(60)})},
font=\sffamily\small,scale=2]
\foreach \X [count=\Y] in {1.6,1.4,1.2,1.2,1}
{
\draw pic (box1-\Y) at (\Y,-\X/2,0) {fake box=white!70!gray with dimensions 0.5 and {2*\X} and 1*\X};
}
\end{tikzpicture}
\end{document}
With the above code, I can get the below figure:
However, I don't want text on all the blocks but just on the first block only (as can be seen in the orange figure). I would like to adapt the code to produce the orange figure.
Best Answer
Something like this?