\section{Hard\+TanH$<$ Input\+Data\+Type, Output\+Data\+Type $>$ Class Template Reference}
\label{classmlpack_1_1ann_1_1HardTanH}\index{Hard\+Tan\+H$<$ Input\+Data\+Type, Output\+Data\+Type $>$@{Hard\+Tan\+H$<$ Input\+Data\+Type, Output\+Data\+Type $>$}}


The Hard Tanh activation function, defined by.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Hard\+TanH} (const double max\+Value=1, const double min\+Value=-\/1)
\begin{DoxyCompactList}\small\item\em Create the \doxyref{Hard\+TanH}{p.}{classmlpack_1_1ann_1_1HardTanH} object using the specified parameters. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Data\+Type $>$ }\\void \textbf{ Backward} (const Data\+Type \&input, const Data\+Type \&gy, Data\+Type \&g)
\begin{DoxyCompactList}\small\item\em Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. \end{DoxyCompactList}\item 
Output\+Data\+Type const  \& \textbf{ Delta} () const
\begin{DoxyCompactList}\small\item\em Get the delta. \end{DoxyCompactList}\item 
Output\+Data\+Type \& \textbf{ Delta} ()
\begin{DoxyCompactList}\small\item\em Modify the delta. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Input\+Type , typename Output\+Type $>$ }\\void \textbf{ Forward} (const Input\+Type \&input, Output\+Type \&output)
\begin{DoxyCompactList}\small\item\em Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. \end{DoxyCompactList}\item 
double const  \& \textbf{ Max\+Value} () const
\begin{DoxyCompactList}\small\item\em Get the maximum value. \end{DoxyCompactList}\item 
double \& \textbf{ Max\+Value} ()
\begin{DoxyCompactList}\small\item\em Modify the maximum value. \end{DoxyCompactList}\item 
double const  \& \textbf{ Min\+Value} () const
\begin{DoxyCompactList}\small\item\em Get the minimum value. \end{DoxyCompactList}\item 
double \& \textbf{ Min\+Value} ()
\begin{DoxyCompactList}\small\item\em Modify the minimum value. \end{DoxyCompactList}\item 
Output\+Data\+Type const  \& \textbf{ Output\+Parameter} () const
\begin{DoxyCompactList}\small\item\em Get the output parameter. \end{DoxyCompactList}\item 
Output\+Data\+Type \& \textbf{ Output\+Parameter} ()
\begin{DoxyCompactList}\small\item\em Modify the output parameter. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Archive $>$ }\\void \textbf{ serialize} (Archive \&ar, const unsigned int)
\begin{DoxyCompactList}\small\item\em Serialize the layer. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Input\+Data\+Type = arma\+::mat, typename Output\+Data\+Type = arma\+::mat$>$\newline
class mlpack\+::ann\+::\+Hard\+Tan\+H$<$ Input\+Data\+Type, Output\+Data\+Type $>$}

The Hard Tanh activation function, defined by. 

\begin{eqnarray*} f(x) &=& \left\{ \begin{array}{lr} max & : x > maxValue \\ min & : x \le minValue \\ x & : otherwise \end{array} \right. \\ f'(x) &=& \left\{ \begin{array}{lr} 0 & : x > maxValue \\ 0 & : x \le minValue \\ 1 & : otherwise \end{array} \right. \end{eqnarray*}


\begin{DoxyTemplParams}{Template Parameters}
{\em Input\+Data\+Type} & Type of the input data (arma\+::colvec, arma\+::mat, arma\+::sp\+\_\+mat or arma\+::cube). \\
\hline
{\em Output\+Data\+Type} & Type of the output data (arma\+::colvec, arma\+::mat, arma\+::sp\+\_\+mat or arma\+::cube). \\
\hline
\end{DoxyTemplParams}


Definition at line 49 of file hard\+\_\+tanh.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a100d6ec0add89f1443eb3a5c5497a82b}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Hard\+TanH@{Hard\+TanH}}
\index{Hard\+TanH@{Hard\+TanH}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Hard\+Tan\+H()}
{\footnotesize\ttfamily \textbf{ Hard\+TanH} (\begin{DoxyParamCaption}\item[{const double}]{max\+Value = {\ttfamily 1},  }\item[{const double}]{min\+Value = {\ttfamily -\/1} }\end{DoxyParamCaption})}



Create the \doxyref{Hard\+TanH}{p.}{classmlpack_1_1ann_1_1HardTanH} object using the specified parameters. 

The range of the linear region can be adjusted by specifying the max\+Value and min\+Value. Default (max\+Value = 1, min\+Value = -\/1).


\begin{DoxyParams}{Parameters}
{\em max\+Value} & Range of the linear region maximum value. \\
\hline
{\em min\+Value} & Range of the linear region minimum value. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1ann_1_1HardTanH_aef8c56f1f8624bd006afec8b3bcda9d6}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Backward@{Backward}}
\index{Backward@{Backward}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Backward()}
{\footnotesize\ttfamily void Backward (\begin{DoxyParamCaption}\item[{const Data\+Type \&}]{input,  }\item[{const Data\+Type \&}]{gy,  }\item[{Data\+Type \&}]{g }\end{DoxyParamCaption})}



Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. 

Using the results from the feed forward pass.


\begin{DoxyParams}{Parameters}
{\em input} & The propagated input activation. \\
\hline
{\em gy} & The backpropagated error. \\
\hline
{\em g} & The calculated gradient. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a797f7edb44dd081e5e2b3cc316eef6bd}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Delta@{Delta}}
\index{Delta@{Delta}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Delta()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily Output\+Data\+Type const\& Delta (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the delta. 



Definition at line 92 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_ad6601342d560219ce951d554e69e5e87}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Delta@{Delta}}
\index{Delta@{Delta}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Delta()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Output\+Data\+Type\& Delta (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the delta. 



Definition at line 94 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a09440df0a90bdcc766e56e097d91205b}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Forward@{Forward}}
\index{Forward@{Forward}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Forward()}
{\footnotesize\ttfamily void Forward (\begin{DoxyParamCaption}\item[{const Input\+Type \&}]{input,  }\item[{Output\+Type \&}]{output }\end{DoxyParamCaption})}



Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. 


\begin{DoxyParams}{Parameters}
{\em input} & Input data used for evaluating the specified function. \\
\hline
{\em output} & Resulting output activation. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a623a4714a5eebaa93e608d60dcf06e27}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Max\+Value@{Max\+Value}}
\index{Max\+Value@{Max\+Value}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Max\+Value()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double const\& Max\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the maximum value. 



Definition at line 97 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_afb2395e0938ffd53260ec80fe4a3fd29}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Max\+Value@{Max\+Value}}
\index{Max\+Value@{Max\+Value}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Max\+Value()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double\& Max\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the maximum value. 



Definition at line 99 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a4704bc5118b3361e1fee1fec6cf29090}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Min\+Value@{Min\+Value}}
\index{Min\+Value@{Min\+Value}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Min\+Value()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double const\& Min\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the minimum value. 



Definition at line 102 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a3f44631970deafe05a5c6d3de3f71da0}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Min\+Value@{Min\+Value}}
\index{Min\+Value@{Min\+Value}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Min\+Value()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double\& Min\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the minimum value. 



Definition at line 104 of file hard\+\_\+tanh.\+hpp.



References Hard\+Tan\+H$<$ Input\+Data\+Type, Output\+Data\+Type $>$\+::serialize().

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a0ee21c2a36e5abad1e7a9d5dd00849f9}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Output\+Parameter@{Output\+Parameter}}
\index{Output\+Parameter@{Output\+Parameter}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Output\+Parameter()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily Output\+Data\+Type const\& Output\+Parameter (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the output parameter. 



Definition at line 87 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_a21d5f745f02c709625a4ee0907f004a5}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!Output\+Parameter@{Output\+Parameter}}
\index{Output\+Parameter@{Output\+Parameter}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{Output\+Parameter()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Output\+Data\+Type\& Output\+Parameter (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the output parameter. 



Definition at line 89 of file hard\+\_\+tanh.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1HardTanH_af0dd9205158ccf7bcfcd8ff81f79c927}} 
\index{mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::ann\+::\+Hard\+TanH@{mlpack\+::ann\+::\+Hard\+TanH}}
\subsubsection{serialize()}
{\footnotesize\ttfamily void serialize (\begin{DoxyParamCaption}\item[{Archive \&}]{ar,  }\item[{const unsigned}]{int }\end{DoxyParamCaption})}



Serialize the layer. 



Referenced by Hard\+Tan\+H$<$ Input\+Data\+Type, Output\+Data\+Type $>$\+::\+Min\+Value().



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+0/src/mlpack/methods/ann/layer/\textbf{ hard\+\_\+tanh.\+hpp}\end{DoxyCompactItemize}
