如何格式化此表?我不知道如何处理图像...
\begin{table}[h]
\centering
\begin{tabular}{llll}
\hline
\multicolumn{1}{l}{Name} & \multicolumn{1}{l}{Function} & \multicolumn{1}{l}{Derivative} & \multicolumn{1}{l}{Figure} \\ \hline
Sigmoid & $\sigma(x)=\frac{1}{1+e^{-x}}$ & $f'(x)=f(x)(1-f(x))^2$ & \includegraphics[width=0.2\textwidth]{sigmoid}\\
tanh & $\sigma(x)=\frac{e^x-e^{-x}}{e^z+e^{-z}} $ & $f'(x)=1-f(x)^2$ & \includegraphics[width=0.2\textwidth]{tanh} \\
ReLU & $f(x) \left\{\begin{matrix}
0 & if \; x<0 \\
x & if \;x \geq 0.
\end{matrix}\right.$ & $f(x) \left\{\begin{matrix}
0 & if \; x<0 \\
x & if \;x \geq 0.
\end{matrix}\right.$ & \includegraphics[width=0.2\textwidth]{relu} \\
Softmax & $f(x)=\frac{e^x}{\sum_i e^x}$ & $f'(x)=\frac{e^x}{\sum_i e^x} - \frac{(e^x)^2}{(\sum_i e^x)^2}$ &
\end{tabular}
\caption{Non-linear activation functions.}
\label{tab:activationfct}
\end{table}
当前输出如下所示:
表中的图像如下:
[
答案1
采纳我的答案到您的代码片段(您的问题是重复的,但是由于您的代码片段有一些题外话,请参见姆韦下面我写了这个答案):
\documentclass{scrreprt}
\usepackage[export, demo]{adjustbox} % in real document delete option "demo"
% adjustbox call "graphicx"
% "adjustbox" call "graphicx" plus add many function
% for manipulating boxes, among them here is used "valign"
\usepackage{cellspace, % for adding vertical space around cells' contents
tabularx}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\addparagraphcolumntypes{X}
\usepackage{ragged2e}
\usepackage{amsmath} % added
\begin{document}
\begin{table}[htb]
\centering
\setkeys{Gin}{width=0.2\textwidth} % with real images should be sufficient defined only image width
\begin{tabular}{l *{2}{>{$\displaystyle}Sl<{$}} Sl} % changed
\hline
{Name} & {Function}
& {Derivative}
& {Figure} \\
\hline
Sigmoid & \sigma(x)=\frac{1}{1+e^{-x}}
& f'(x)=f(x)(1-f(x))^2
& \includegraphics[valign=c]{sigmoid} \\
tanh & \sigma(x)=\frac{e^x-e^{-x}}{e^z+e^{-z}}
& f'(x)=1-f(x)^2
& \includegraphics[valign=c]{tanh} \\
ReLU & f(x) \begin{cases} % changed and corrected
0 & if \; x<0 \\
x & if \;x \geq 0.
\end{cases}
& f(x) \begin{cases} % changed and corrected
0 & if \; x<0 \\
x & if \;x \geq 0.
\end{cases}
& \includegraphics[valign=c]{relu} \\
Softmax & f(x)=\frac{e^x}{\sum_i e^x}
& f'(x)=\frac{e^x}{\sum_i e^x} - \frac{(e^x)^2}{(\sum_i e^x)^2}
& \\
\hline
\end{tabular}
\caption{Non-linear activation functions.}
\label{tab:activationfct}
\end{table}
\end{document}
答案2
我想说的是,用 Ti 绘制这些函数更有趣钾Z. 然后,您将可以完全控制垂直放置baseline
,如下图所示,如果您决定添加轴标签等,它们将具有相同的字体和外观。我利用这个机会修复了一些拼写错误,并cases
在适当的地方使用。还请注意,您可以使用scale
来使图表更大。
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{llll}
\hline
\multicolumn{1}{l}{Name} & \multicolumn{1}{l}{Function} & \multicolumn{1}{l}{Derivative} & \multicolumn{1}{l}{Figure} \\
\hline
Sigmoid & $\sigma(x)=\frac{1}{1+e^{-x}}$ & $f'(x)=f(x)(1-f(x))^2$ &
\begin{tikzpicture}[baseline={(0,0.2)}]
\draw (-1,0) -- (1,0);
\draw (0,0) -- (0,1);
\draw plot[domain=-1:1,variable=\x] ({\x},{1/(1+exp(-4*\x))});
\end{tikzpicture}\\
\\
tanh & $\sigma(x)=\frac{e^x-e^{-x}}{e^z+e^{-z}} $ & $f'(x)=1-f(x)^2$
& \begin{tikzpicture}[baseline={(0,0)}]
\draw (-1,0) -- (1,0);
\draw (0,-1) -- (0,1);
\draw plot[domain=-1:1,variable=\x] ({\x},{tanh(4*\x)});
\end{tikzpicture} \\
ReLU & $f(x) =\begin{cases}
0 & ~\text{if}~ x<0 \\
x & ~\text{if}~x \geq 0.
\end{cases}$ & $f'(x)=\begin{cases}
0 & ~\text{if}~ x<0 \\
x & ~\text{if}~1 \geq 0.
\end{cases} $ &
\begin{tikzpicture}[baseline={(0,0.5)}]
\draw (-1,0) -- (1,0);
\draw (0,0) -- (0,1);
\draw plot[domain=-1:1,variable=\x] ({\x},{ifthenelse(\x<0,0,\x)});
\end{tikzpicture}\\
Softmax & $f(x)=\frac{e^x}{\sum_i e^x}$ & $f'(x)=\frac{e^x}{\sum_i e^x} - \frac{(e^x)^2}{(\sum_i e^x)^2}$ &
\end{tabular}
\caption{Non-linear activation functions.}
\label{tab:activationfct}
\end{table}
\end{document}