3

How to format this table? I do not know how to handle the images...

\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}

The current output looks like this:

enter image description here

These are the images in the table:

[enter image description here

enter image description here enter image description here

  • there i tons of similar questions ... you need to move image baseline to the center of images. see tex.stackexchange.com/questions/19080/…, or tex.stackexchange.com/questions/430760/… – Zarko May 11 '18 at 21:23
  • 1
    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a \documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we cannot reproduce your problem from the code that you have given us which makes it harder to help you. – Andrew May 11 '18 at 21:28
3

adopted my answer to your code fragment (your question is duplicate, however since your code fragment has some off-topic issues, see mwe below i wrote this answer):

\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}

enter image description here

3

I'd like to argue that it is more fun to draw these functions with TikZ. You'll then have full control over the vertical placement with baseline, as I illustrate below, and if you decide to add axis labels etc. they'll have the same fonts and appearance. And I used the opportunity to fix a few typos and to use cases where appropriate. Note also that you can use scale to make the plots larger.

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.