\hypertarget{classnntrainer_1_1Weight}{}\doxysection{nntrainer\+::Weight Class Reference}
\label{classnntrainer_1_1Weight}\index{nntrainer::Weight@{nntrainer::Weight}}


\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} extends over \mbox{\hyperlink{classnntrainer_1_1Var__Grad}{Var\+\_\+\+Grad}} with regularization \& optimizer updates.  




{\ttfamily \#include $<$weight.\+h$>$}



Inheritance diagram for nntrainer\+::Weight\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=191pt]{classnntrainer_1_1Weight__inherit__graph}
\end{center}
\end{figure}


Collaboration diagram for nntrainer\+::Weight\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=191pt]{classnntrainer_1_1Weight__coll__graph}
\end{center}
\end{figure}
\doxysubsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
typedef \mbox{\hyperlink{namespacenntrainer_a486fa79107b2f54f85fd24a6e76a75dc}{Weight\+Spec}} \mbox{\hyperlink{classnntrainer_1_1Weight_a66ae682f4206db214060c34d749e348c}{Spec}}
\begin{DoxyCompactList}\small\item\em Specification of the \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_a0c1aac9c68a49475820c6a3e18b625df}\label{classnntrainer_1_1Weight_a0c1aac9c68a49475820c6a3e18b625df}} 
\mbox{\hyperlink{classnntrainer_1_1Weight_a0c1aac9c68a49475820c6a3e18b625df}{Weight}} ()
\begin{DoxyCompactList}\small\item\em \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} default constructor. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_acd1682051a188d23aa4d96d8c19585a8}{Weight}} (const Tensor\+Dim \&dim, const Tensor\+::\+Initializer init=Tensor\+::\+Initializer\+::\+X\+A\+V\+I\+E\+R\+\_\+\+U\+N\+I\+F\+O\+RM, const \mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58}{Weight\+Regularizer}} reg=\mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58ab50339a10e1de285ac99d4c3990b8693}{Weight\+Regularizer\+::\+N\+O\+NE}}, const float reg\+\_\+const=1.\+0f, const float decay=0.\+0f, const float clip\+\_\+by\+\_\+global\+\_\+norm=0.\+0f, bool ng=true, bool alloc\+\_\+now=false, std\+::string name=\char`\"{}\char`\"{})
\begin{DoxyCompactList}\small\item\em Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_adb15b955a49bb6960a177c2349c70364}{Weight}} (const \mbox{\hyperlink{classnntrainer_1_1Var__Grad_a348805e717af6cb48db25f42a7aaf29f}{Spec}} \&spec, bool alloc\+\_\+now=false)
\begin{DoxyCompactList}\small\item\em Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_a50f07308772ffeaca7ca3b856b21279d}{Weight}} (const Tensor \&v, const Tensor \&g, const std\+::string \&n=\char`\"{}\char`\"{}, bool \mbox{\hyperlink{classnntrainer_1_1Var__Grad_a0e2d9b6e8da948cf26ec56e83d7e70a5}{is\+\_\+dependent}}=false)
\begin{DoxyCompactList}\small\item\em Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_aec84d4adbdc909c3719076f86f0a5d7e}{Weight}} (Tensor $\ast$v, Tensor $\ast$g, const \mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58}{Weight\+Regularizer}} reg, const float reg\+\_\+const, const float decay, bool \mbox{\hyperlink{classnntrainer_1_1Var__Grad_a0e2d9b6e8da948cf26ec56e83d7e70a5}{is\+\_\+dependent}}=false, const float max\+\_\+norm=0.\+0f)
\begin{DoxyCompactList}\small\item\em Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_a1ca947ede00db880dd5a2bc40627a1ec}{Weight}} (const \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&rhs)=default
\begin{DoxyCompactList}\small\item\em Copy constructor for weight. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight_abc1fe30dad982aa63fe906082902076a}{Weight}} (\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&\&rhs)=default
\begin{DoxyCompactList}\small\item\em Move constructor for weight. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \& \mbox{\hyperlink{classnntrainer_1_1Weight_acd75594ae90711307c5a297f3c4fd595}{operator=}} (const \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&rhs)=default
\begin{DoxyCompactList}\small\item\em copy assigment \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \& \mbox{\hyperlink{classnntrainer_1_1Weight_aed0562c5877139c04fe3eb4ee242ed9b}{operator=}} (\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&\&rhs)=default
\begin{DoxyCompactList}\small\item\em move assignment \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \mbox{\hyperlink{classnntrainer_1_1Weight_a912d6aa5ed1d982eb7a93bd88805a332}{clone}} () const
\begin{DoxyCompactList}\small\item\em Clone the currnet object. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_ac6961a2b578c89cf74724f5ec310757d}\label{classnntrainer_1_1Weight_ac6961a2b578c89cf74724f5ec310757d}} 
void \mbox{\hyperlink{classnntrainer_1_1Weight_ac6961a2b578c89cf74724f5ec310757d}{clear\+Optimizer\+Variables}} ()
\begin{DoxyCompactList}\small\item\em Clear optimizer variables. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classnntrainer_1_1Weight_a29b5cc1a2f2b68520caea8c4f34d22d7}{set\+Optimizer\+Variables}} (std\+::vector$<$ Tensor $\ast$ $>$ tensors)
\begin{DoxyCompactList}\small\item\em Add optimizer variables. \end{DoxyCompactList}\item 
Tensor \& \mbox{\hyperlink{classnntrainer_1_1Weight_a46d04eaff5d290f7add685a985f5d555}{get\+Optimizer\+Variable\+Ref}} (unsigned int idx)
\begin{DoxyCompactList}\small\item\em Get optimizer variable reference. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classnntrainer_1_1Weight_a47ed253b981e9c1c3a6a661cb9726fba}{get\+Num\+Opt\+Variable}} ()
\begin{DoxyCompactList}\small\item\em Get number of optimizer variable. \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classnntrainer_1_1Weight_ab9e973113274bffbbbbf1e0489ed46e8}{is\+Weight\+Regularizer\+L2\+Norm}} ()
\begin{DoxyCompactList}\small\item\em check if weight regularizer type is l2norm \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classnntrainer_1_1Weight_a1f44846956068e8c106fc7e477773710}{is\+Weight\+Decay}} ()
\begin{DoxyCompactList}\small\item\em check if weight decay is enabled \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_a07cc6cb75a44f4bf86cb30370682d533}\label{classnntrainer_1_1Weight_a07cc6cb75a44f4bf86cb30370682d533}} 
float \mbox{\hyperlink{classnntrainer_1_1Weight_a07cc6cb75a44f4bf86cb30370682d533}{get\+Regularization\+Loss}} ()
\begin{DoxyCompactList}\small\item\em Get loss from the regularization of the weight. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_a1284afdf5ea2554693aa2083948a409c}\label{classnntrainer_1_1Weight_a1284afdf5ea2554693aa2083948a409c}} 
void \mbox{\hyperlink{classnntrainer_1_1Weight_a1284afdf5ea2554693aa2083948a409c}{calc\+Regularization\+Gradient}} ()
\begin{DoxyCompactList}\small\item\em Calculate gradient from the regularization of the weight. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_adb387c590db0f0a841e02d310412e25f}\label{classnntrainer_1_1Weight_adb387c590db0f0a841e02d310412e25f}} 
void \mbox{\hyperlink{classnntrainer_1_1Weight_adb387c590db0f0a841e02d310412e25f}{calc\+Weight\+Decay\+Gradient}} ()
\begin{DoxyCompactList}\small\item\em Calculate gradient from the decay of the weight. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classnntrainer_1_1Weight_a309344f2f9d741cfc3cf56a133030bda}\label{classnntrainer_1_1Weight_a309344f2f9d741cfc3cf56a133030bda}} 
void \mbox{\hyperlink{classnntrainer_1_1Weight_a309344f2f9d741cfc3cf56a133030bda}{apply\+Gradient}} (double lr)
\begin{DoxyCompactList}\small\item\em Apply the gradient to the weight. \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classnntrainer_1_1Weight_a5e855c4d879415395e2aae15ad2b2fb3}{is\+Gradient\+Clip\+By\+Global\+Norm}} () const
\begin{DoxyCompactList}\small\item\em Check if the gradient is supposed to be clipped by global norm. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classnntrainer_1_1Weight_a52b249a4095816cf3b75bdde5c1cc024}{clip\+Gradient\+By\+Global\+Norm}} (const float global\+\_\+norm)
\begin{DoxyCompactList}\small\item\em clip the gradient value based on the given global norm \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static bool \mbox{\hyperlink{classnntrainer_1_1Weight_acacf7c244feff88f5271cfa0c17b41dc}{is\+Gradient\+Clip\+By\+Global\+Norm}} (const float max\+\_\+norm)
\begin{DoxyCompactList}\small\item\em Check if the gradient is supposed to be clipped by global norm with the given max\+\_\+norm value. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Friends}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{classnntrainer_1_1Weight_a103d2a09f04bea44c089967ff04b914e}{swap}} (\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&lhs, \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&rhs) noexcept
\begin{DoxyCompactList}\small\item\em Swap for weight. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Additional Inherited Members}


\doxysubsection{Detailed Description}
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} extends over \mbox{\hyperlink{classnntrainer_1_1Var__Grad}{Var\+\_\+\+Grad}} with regularization \& optimizer updates. 

Definition at line 29 of file weight.\+h.



\doxysubsection{Member Typedef Documentation}
\mbox{\Hypertarget{classnntrainer_1_1Weight_a66ae682f4206db214060c34d749e348c}\label{classnntrainer_1_1Weight_a66ae682f4206db214060c34d749e348c}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Spec@{Spec}}
\index{Spec@{Spec}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Spec}{Spec}}
{\footnotesize\ttfamily typedef \mbox{\hyperlink{namespacenntrainer_a486fa79107b2f54f85fd24a6e76a75dc}{Weight\+Spec}} \mbox{\hyperlink{classnntrainer_1_1Weight_a66ae682f4206db214060c34d749e348c}{nntrainer\+::\+Weight\+::\+Spec}}}



Specification of the \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}. 

The tuple values are dimension, initializer, regularizer, regularizer\+\_\+constant, need\+\_\+gradient property amd name of the \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. 

Definition at line 37 of file weight.\+h.



\doxysubsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{classnntrainer_1_1Weight_acd1682051a188d23aa4d96d8c19585a8}\label{classnntrainer_1_1Weight_acd1682051a188d23aa4d96d8c19585a8}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [1/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{const Tensor\+Dim \&}]{dim,  }\item[{const Tensor\+::\+Initializer}]{init = {\ttfamily Tensor\+:\+:Initializer\+:\+:XAVIER\+\_\+UNIFORM},  }\item[{const \mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58}{Weight\+Regularizer}}}]{reg = {\ttfamily \mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58ab50339a10e1de285ac99d4c3990b8693}{Weight\+Regularizer\+::\+N\+O\+NE}}},  }\item[{const float}]{reg\+\_\+const = {\ttfamily 1.0f},  }\item[{const float}]{decay = {\ttfamily 0.0f},  }\item[{const float}]{clip\+\_\+by\+\_\+global\+\_\+norm = {\ttfamily 0.0f},  }\item[{bool}]{ng = {\ttfamily true},  }\item[{bool}]{alloc\+\_\+now = {\ttfamily false},  }\item[{std\+::string}]{name = {\ttfamily \char`\"{}\char`\"{}} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [explicit]}}



Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. 


\begin{DoxyParams}{Parameters}
{\em dim} & Variable and gradient tensor dimension \\
\hline
{\em init} & Initializer for the weight \\
\hline
{\em reg} & Regularizer for the weight \\
\hline
{\em reg\+\_\+const} & Constant multiplier for regularizer \\
\hline
{\em ng} & If the variable needs gradient \\
\hline
{\em alloc\+\_\+now} & The memory for the weight tensors be allocated upon init \\
\hline
{\em name} & Name for this weight \\
\hline
\end{DoxyParams}


Definition at line 21 of file weight.\+cpp.

\mbox{\Hypertarget{classnntrainer_1_1Weight_adb15b955a49bb6960a177c2349c70364}\label{classnntrainer_1_1Weight_adb15b955a49bb6960a177c2349c70364}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [2/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classnntrainer_1_1Var__Grad_a348805e717af6cb48db25f42a7aaf29f}{Spec}} \&}]{spec,  }\item[{bool}]{alloc\+\_\+now = {\ttfamily false} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}



Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. 


\begin{DoxyParams}{Parameters}
{\em spec} & \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} specification \\
\hline
\end{DoxyParams}


Definition at line 73 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a50f07308772ffeaca7ca3b856b21279d}\label{classnntrainer_1_1Weight_a50f07308772ffeaca7ca3b856b21279d}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [3/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{const Tensor \&}]{v,  }\item[{const Tensor \&}]{g,  }\item[{const std\+::string \&}]{n = {\ttfamily \char`\"{}\char`\"{}},  }\item[{bool}]{is\+\_\+dependent = {\ttfamily false} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}



Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. 


\begin{DoxyParams}{Parameters}
{\em v} & Already created variable object \\
\hline
{\em g} & Already created gradient object \\
\hline
{\em n} & Name for this \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}\\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
This is primarily used to created wrapper of variable extracted from context. If needed, add support for regularizer, and opt\+\_\+vars.

This A\+PI is not recommended for usage and must be used for internal uses only, as \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} does not own the tensors v and g, and can go invalid if the owner of these tensors free the tensors. 
\end{DoxyNote}


Definition at line 99 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_aec84d4adbdc909c3719076f86f0a5d7e}\label{classnntrainer_1_1Weight_aec84d4adbdc909c3719076f86f0a5d7e}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [4/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{Tensor $\ast$}]{v,  }\item[{Tensor $\ast$}]{g,  }\item[{const \mbox{\hyperlink{namespacenntrainer_a9b456193e005bc14834eb1ecc03a7d58}{Weight\+Regularizer}}}]{reg,  }\item[{const float}]{reg\+\_\+const,  }\item[{const float}]{decay,  }\item[{bool}]{is\+\_\+dependent = {\ttfamily false},  }\item[{const float}]{max\+\_\+norm = {\ttfamily 0.0f} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}



Construct a new \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} object. 


\begin{DoxyParams}{Parameters}
{\em v} & ptr to already created variable tensor \\
\hline
{\em g} & ptr to already created gradient tensor \\
\hline
{\em reg} & Regularizer for the weight \\
\hline
{\em reg\+\_\+const} & Constant multiplier for regularizer \\
\hline
\end{DoxyParams}


Definition at line 115 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a1ca947ede00db880dd5a2bc40627a1ec}\label{classnntrainer_1_1Weight_a1ca947ede00db880dd5a2bc40627a1ec}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [5/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}



Copy constructor for weight. 


\begin{DoxyParams}{Parameters}
{\em rhs} & weight to construct from \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classnntrainer_1_1Weight_abc1fe30dad982aa63fe906082902076a}\label{classnntrainer_1_1Weight_abc1fe30dad982aa63fe906082902076a}} 
\index{nntrainer::Weight@{nntrainer::Weight}!Weight@{Weight}}
\index{Weight@{Weight}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{Weight()}{Weight()}\hspace{0.1cm}{\footnotesize\ttfamily [6/6]}}
{\footnotesize\ttfamily nntrainer\+::\+Weight\+::\+Weight (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&\&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}



Move constructor for weight. 


\begin{DoxyParams}{Parameters}
{\em rhs} & weight to construct from \\
\hline
\end{DoxyParams}


\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classnntrainer_1_1Weight_a52b249a4095816cf3b75bdde5c1cc024}\label{classnntrainer_1_1Weight_a52b249a4095816cf3b75bdde5c1cc024}} 
\index{nntrainer::Weight@{nntrainer::Weight}!clipGradientByGlobalNorm@{clipGradientByGlobalNorm}}
\index{clipGradientByGlobalNorm@{clipGradientByGlobalNorm}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{clipGradientByGlobalNorm()}{clipGradientByGlobalNorm()}}
{\footnotesize\ttfamily void nntrainer\+::\+Weight\+::clip\+Gradient\+By\+Global\+Norm (\begin{DoxyParamCaption}\item[{const float}]{global\+\_\+norm }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



clip the gradient value based on the given global norm 


\begin{DoxyParams}{Parameters}
{\em global\+\_\+norm} & the global norm for all the weights \\
\hline
\end{DoxyParams}


Definition at line 284 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a912d6aa5ed1d982eb7a93bd88805a332}\label{classnntrainer_1_1Weight_a912d6aa5ed1d982eb7a93bd88805a332}} 
\index{nntrainer::Weight@{nntrainer::Weight}!clone@{clone}}
\index{clone@{clone}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{clone()}{clone()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} nntrainer\+::\+Weight\+::clone (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Clone the currnet object. 

\begin{DoxyReturn}{Returns}
Cloned copy 
\end{DoxyReturn}


Definition at line 176 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a47ed253b981e9c1c3a6a661cb9726fba}\label{classnntrainer_1_1Weight_a47ed253b981e9c1c3a6a661cb9726fba}} 
\index{nntrainer::Weight@{nntrainer::Weight}!getNumOptVariable@{getNumOptVariable}}
\index{getNumOptVariable@{getNumOptVariable}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{getNumOptVariable()}{getNumOptVariable()}}
{\footnotesize\ttfamily int nntrainer\+::\+Weight\+::get\+Num\+Opt\+Variable (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Get number of optimizer variable. 


\begin{DoxyRetVals}{Return values}
{\em number} & of optimizer variable \\
\hline
\end{DoxyRetVals}


Definition at line 210 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a46d04eaff5d290f7add685a985f5d555}\label{classnntrainer_1_1Weight_a46d04eaff5d290f7add685a985f5d555}} 
\index{nntrainer::Weight@{nntrainer::Weight}!getOptimizerVariableRef@{getOptimizerVariableRef}}
\index{getOptimizerVariableRef@{getOptimizerVariableRef}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{getOptimizerVariableRef()}{getOptimizerVariableRef()}}
{\footnotesize\ttfamily Tensor\& nntrainer\+::\+Weight\+::get\+Optimizer\+Variable\+Ref (\begin{DoxyParamCaption}\item[{unsigned int}]{idx }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Get optimizer variable reference. 


\begin{DoxyParams}{Parameters}
{\em idx} & Index of the optimizer variable to get \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em Reference} & of the optimizer variable \\
\hline
\end{DoxyRetVals}


Definition at line 204 of file weight.\+h.

Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classnntrainer_1_1Weight_a46d04eaff5d290f7add685a985f5d555_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{classnntrainer_1_1Weight_a5e855c4d879415395e2aae15ad2b2fb3}\label{classnntrainer_1_1Weight_a5e855c4d879415395e2aae15ad2b2fb3}} 
\index{nntrainer::Weight@{nntrainer::Weight}!isGradientClipByGlobalNorm@{isGradientClipByGlobalNorm}}
\index{isGradientClipByGlobalNorm@{isGradientClipByGlobalNorm}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{isGradientClipByGlobalNorm()}{isGradientClipByGlobalNorm()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily bool nntrainer\+::\+Weight\+::is\+Gradient\+Clip\+By\+Global\+Norm (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Check if the gradient is supposed to be clipped by global norm. 

\begin{DoxyReturn}{Returns}
true if it is to be clipped 

false otherwise 
\end{DoxyReturn}


Definition at line 275 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_acacf7c244feff88f5271cfa0c17b41dc}\label{classnntrainer_1_1Weight_acacf7c244feff88f5271cfa0c17b41dc}} 
\index{nntrainer::Weight@{nntrainer::Weight}!isGradientClipByGlobalNorm@{isGradientClipByGlobalNorm}}
\index{isGradientClipByGlobalNorm@{isGradientClipByGlobalNorm}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{isGradientClipByGlobalNorm()}{isGradientClipByGlobalNorm()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily static bool nntrainer\+::\+Weight\+::is\+Gradient\+Clip\+By\+Global\+Norm (\begin{DoxyParamCaption}\item[{const float}]{max\+\_\+norm }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Check if the gradient is supposed to be clipped by global norm with the given max\+\_\+norm value. 


\begin{DoxyParams}{Parameters}
{\em max\+\_\+norm} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if it is to be clipped 

false otherwise 
\end{DoxyReturn}


Definition at line 265 of file weight.\+h.

\mbox{\Hypertarget{classnntrainer_1_1Weight_a1f44846956068e8c106fc7e477773710}\label{classnntrainer_1_1Weight_a1f44846956068e8c106fc7e477773710}} 
\index{nntrainer::Weight@{nntrainer::Weight}!isWeightDecay@{isWeightDecay}}
\index{isWeightDecay@{isWeightDecay}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{isWeightDecay()}{isWeightDecay()}}
{\footnotesize\ttfamily bool nntrainer\+::\+Weight\+::is\+Weight\+Decay (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



check if weight decay is enabled 

\begin{DoxyReturn}{Returns}
true if weight decay is enabled else false 
\end{DoxyReturn}


Definition at line 224 of file weight.\+h.

Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classnntrainer_1_1Weight_a1f44846956068e8c106fc7e477773710_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{classnntrainer_1_1Weight_ab9e973113274bffbbbbf1e0489ed46e8}\label{classnntrainer_1_1Weight_ab9e973113274bffbbbbf1e0489ed46e8}} 
\index{nntrainer::Weight@{nntrainer::Weight}!isWeightRegularizerL2Norm@{isWeightRegularizerL2Norm}}
\index{isWeightRegularizerL2Norm@{isWeightRegularizerL2Norm}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{isWeightRegularizerL2Norm()}{isWeightRegularizerL2Norm()}}
{\footnotesize\ttfamily bool nntrainer\+::\+Weight\+::is\+Weight\+Regularizer\+L2\+Norm (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



check if weight regularizer type is l2norm 

\begin{DoxyReturn}{Returns}
bool is weight regrulatizer type is L2 Norm 
\end{DoxyReturn}


Definition at line 216 of file weight.\+h.

Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classnntrainer_1_1Weight_ab9e973113274bffbbbbf1e0489ed46e8_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{classnntrainer_1_1Weight_acd75594ae90711307c5a297f3c4fd595}\label{classnntrainer_1_1Weight_acd75594ae90711307c5a297f3c4fd595}} 
\index{nntrainer::Weight@{nntrainer::Weight}!operator=@{operator=}}
\index{operator=@{operator=}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}\& nntrainer\+::\+Weight\+::operator= (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}



copy assigment 


\begin{DoxyParams}{Parameters}
{\em rhs} & copy from \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}\& Updated weight 
\end{DoxyReturn}
\mbox{\Hypertarget{classnntrainer_1_1Weight_aed0562c5877139c04fe3eb4ee242ed9b}\label{classnntrainer_1_1Weight_aed0562c5877139c04fe3eb4ee242ed9b}} 
\index{nntrainer::Weight@{nntrainer::Weight}!operator=@{operator=}}
\index{operator=@{operator=}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}\& nntrainer\+::\+Weight\+::operator= (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&\&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}



move assignment 


\begin{DoxyParams}{Parameters}
{\em rhs} & move from \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}}\& Updated weight 
\end{DoxyReturn}
\mbox{\Hypertarget{classnntrainer_1_1Weight_a29b5cc1a2f2b68520caea8c4f34d22d7}\label{classnntrainer_1_1Weight_a29b5cc1a2f2b68520caea8c4f34d22d7}} 
\index{nntrainer::Weight@{nntrainer::Weight}!setOptimizerVariables@{setOptimizerVariables}}
\index{setOptimizerVariables@{setOptimizerVariables}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{setOptimizerVariables()}{setOptimizerVariables()}}
{\footnotesize\ttfamily void nntrainer\+::\+Weight\+::set\+Optimizer\+Variables (\begin{DoxyParamCaption}\item[{std\+::vector$<$ Tensor $\ast$ $>$}]{tensors }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Add optimizer variables. 


\begin{DoxyParams}{Parameters}
{\em dim} & Optimizer variable dimension \\
\hline
\end{DoxyParams}


Definition at line 195 of file weight.\+h.



\doxysubsection{Friends And Related Function Documentation}
\mbox{\Hypertarget{classnntrainer_1_1Weight_a103d2a09f04bea44c089967ff04b914e}\label{classnntrainer_1_1Weight_a103d2a09f04bea44c089967ff04b914e}} 
\index{nntrainer::Weight@{nntrainer::Weight}!swap@{swap}}
\index{swap@{swap}!nntrainer::Weight@{nntrainer::Weight}}
\doxysubsubsection{\texorpdfstring{swap}{swap}}
{\footnotesize\ttfamily void swap (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&}]{lhs,  }\item[{\mbox{\hyperlink{classnntrainer_1_1Weight}{Weight}} \&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}



Swap for weight. 


\begin{DoxyParams}{Parameters}
{\em lhs} & Swap to \\
\hline
{\em rhs} & Swap from \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Only swap gradient if need gradient 
\end{DoxyNote}


Definition at line 131 of file weight.\+h.



The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
tensor/\mbox{\hyperlink{weight_8h}{weight.\+h}}\item 
tensor/\mbox{\hyperlink{weight_8cpp}{weight.\+cpp}}\end{DoxyCompactItemize}
