Ti를 사용하여 CNN(컨벌루션 네트워크)을 표현하기 위한 3D 볼륨의 블록을 그리고 싶습니다.케이Z. 아래는 제가 다시 만들려고 하는 사진입니다.
며칠 동안 이 블록을 만드는 데 어려움을 겪었지만 여전히 많은 진전이 없습니다 :(. Ti가케이여기 Z 닌자들이 도와주나요?
두 번째 슬래브 아래의 수평선은 필요하지 않습니다(자르는 동안 나타남). 감사해요!
아래는 내가 지금까지 시도한 것입니다 (솔루션을 기반으로 함).TikZ로 CNN 그리기)
\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}
위의 코드를 사용하면 아래 그림을 얻을 수 있습니다.
그러나 모든 블록에 텍스트가 있는 것이 아니라 첫 번째 블록에만 텍스트가 필요합니다(주황색 그림에서 볼 수 있음). 주황색 그림을 생성하도록 코드를 조정하고 싶습니다.
답변1
이 같은?
\documentclass[tikz,border=3.14pt]{standalone}
\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[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[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[ultra thin,fill=#1!80!black] (#2,0,0) --++ (0,0,#4) coordinate(-back-bottom-right)
--++ (0,#3,0) --++ (0,0,-#4) -- cycle;
\path[decorate,decoration={text effects along path,text={CONV}}] (#2/2,{2+(#3-2)/2},0) -- (#2/2,0,0);
}
}}
\tikzset{pics/empty 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[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[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[ultra thin,fill=#1!80!black] (#2,0,0) --++ (0,0,#4) coordinate(-back-bottom-right)
--++ (0,#3,0) --++ (0,0,-#4) -- cycle;
}
}}
\begin{document}
\begin{tikzpicture}[x={(1,0)},y={(0,1)},z={({cos(60)},{sin(60)})},
font=\sffamily\small,scale=2]
%
% comment these out if you want to see where the axes point to
% \draw[-latex] (0,0,0) -- (3,0,0) node[below]{$x$};
% \draw[-latex] (0,0,0) -- (0,3,0) node[left]{$y$};
% \draw[-latex] (0,0,0) -- (0,0,3) node[below]{$z$};
% a plane
\foreach \X/\Y [count=\Z] in {0/0.8,0.4/0.6,0.7/0.4,0.9/0.2,1.0/0.2}
{\ifnum\Z=1
\draw pic (box1-\Z) at (\X,-\Y,-\Y/2)
{fake box=orange!90!black with dimensions {\Y} and {4*\Y} and 2*\Y};
\else
\draw pic (box1-\Z) at (\X,-\Y,-\Y/2)
{empty fake box=orange!90!black with dimensions {\Y} and {4*\Y} and 2*\Y};
\fi
}
\end{tikzpicture}
\end{document}