123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- \hypertarget{activation_8hpp_source}{}\doxysection{activation.\+hpp}
- \label{activation_8hpp_source}\index{src/layers/activation.hpp@{src/layers/activation.hpp}}
- \mbox{\hyperlink{activation_8hpp}{Go to the documentation of this file.}}
- \begin{DoxyCode}{0}
- \DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef ACTIVATION\_LAYER\_HPP}}
- \DoxyCodeLine{2 \textcolor{preprocessor}{\#define ACTIVATION\_LAYER\_HPP}}
- \DoxyCodeLine{3 }
- \DoxyCodeLine{4 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{layer_8hpp}{layer.hpp}}"{}}}
- \DoxyCodeLine{5 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{math_8hpp}{math.hpp}}"{}}}
- \DoxyCodeLine{6 }
- \DoxyCodeLine{7 \textcolor{keyword}{namespace }\mbox{\hyperlink{namespace_layer}{Layer}}\{}
- \DoxyCodeLine{9 \textcolor{keyword}{enum} \mbox{\hyperlink{namespace_layer_a154fb338e15b0326915fb7f9c383ef9f}{ActivationMap}}\{}
- \DoxyCodeLine{10 \mbox{\hyperlink{namespace_layer_a154fb338e15b0326915fb7f9c383ef9fa467cf9e29d4001586b13a922da0dc34b}{Sigmoid}} }
- \DoxyCodeLine{11 \};}
- \DoxyCodeLine{12 }
- \DoxyCodeLine{14 \textcolor{keyword}{template}<ActivationMap A> \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} \mbox{\hyperlink{namespace_layer_a8bab25d92aa706e26d241614ff6fe81a}{activation\_map}}(\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}});}
- \DoxyCodeLine{15 }
- \DoxyCodeLine{17 \textcolor{keyword}{template}<ActivationMap A> \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} \mbox{\hyperlink{namespace_layer_ab144999586187c1317641130a7b88013}{activation\_diff\_map}}(\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}});}
- \DoxyCodeLine{18 }
- \DoxyCodeLine{23 \textcolor{keyword}{template}<ActivationMap A> \textcolor{keyword}{class }\mbox{\hyperlink{class_layer_1_1_activation_layer}{ActivationLayer}}:\textcolor{keyword}{public} \mbox{\hyperlink{namespace_layer}{Layer}}\{}
- \DoxyCodeLine{24 \textcolor{keyword}{public}:}
- \DoxyCodeLine{25 \mbox{\hyperlink{class_layer_1_1_activation_layer_a6999fec429ab7f6eafc9ebd5a42a8f76}{ActivationLayer}}(\textcolor{keyword}{const} \textcolor{keywordtype}{size\_t});}
- \DoxyCodeLine{26 \mbox{\hyperlink{class_layer_1_1_activation_layer_aa7059282e1e7eeb17b1e36e594e1f2ac}{\string~ActivationLayer}}()\{\};}
- \DoxyCodeLine{28 \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} \mbox{\hyperlink{class_layer_1_1_activation_layer_a9bc3eb83733b4ee5a4a3c5c50e794478}{feed\_forward}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} \mbox{\hyperlink{class_layer_1_1_layer_af2ebcf019bc0e4b97f41fc9205706665}{x}}) \textcolor{keyword}{override};}
- \DoxyCodeLine{30 \textcolor{keywordtype}{void} \mbox{\hyperlink{class_layer_1_1_activation_layer_a230ad43fde65528cc36021e097f111a4}{init\_nabla}}()\textcolor{keyword}{ override }\{\};}
- \DoxyCodeLine{32 \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} \mbox{\hyperlink{class_layer_1_1_activation_layer_aa946acde267d94523d12465ca8976ab9}{back\_propagation}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} e) \textcolor{keyword}{override};}
- \DoxyCodeLine{34 \textcolor{keywordtype}{void} \mbox{\hyperlink{class_layer_1_1_activation_layer_afbc9f12d792008bbaf6d6c2d0177ebf1}{update}}(\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} eta)\textcolor{keyword}{ override}\{\};}
- \DoxyCodeLine{35 \};}
- \DoxyCodeLine{36 }
- \DoxyCodeLine{37 \textcolor{keyword}{template}<ActivationMap A>}
- \DoxyCodeLine{38 \textcolor{keyword}{inline}}
- \DoxyCodeLine{39 \mbox{\hyperlink{class_layer_1_1_activation_layer_a6999fec429ab7f6eafc9ebd5a42a8f76}{ActivationLayer<A>::ActivationLayer}}(\textcolor{keywordtype}{size\_t} n):\mbox{\hyperlink{namespace_layer}{Layer}}(n,n)\{}
- \DoxyCodeLine{40 \}}
- \DoxyCodeLine{41 }
- \DoxyCodeLine{42 \textcolor{keyword}{template}<ActivationMap A>}
- \DoxyCodeLine{43 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}}
- \DoxyCodeLine{44 \mbox{\hyperlink{class_layer_1_1_activation_layer_a9bc3eb83733b4ee5a4a3c5c50e794478}{ActivationLayer<A>::feed\_forward}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} x\_)\{}
- \DoxyCodeLine{45 x=x\_;}
- \DoxyCodeLine{46 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{size\_t} i=0;i<n;++i)\{}
- \DoxyCodeLine{47 y[i]=activation\_map<A>(x[i]);}
- \DoxyCodeLine{48 \}}
- \DoxyCodeLine{49 \textcolor{keywordflow}{return} y;}
- \DoxyCodeLine{50 \}}
- \DoxyCodeLine{51 }
- \DoxyCodeLine{52 \textcolor{keyword}{template}<ActivationMap A>}
- \DoxyCodeLine{53 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}}
- \DoxyCodeLine{54 \mbox{\hyperlink{class_layer_1_1_activation_layer_aa946acde267d94523d12465ca8976ab9}{ActivationLayer<A>::back\_propagation}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} e)\{}
- \DoxyCodeLine{55 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{size\_t} i=0;i<n;++i)\{}
- \DoxyCodeLine{56 d[i]=activation\_diff\_map<A>(x[i])*e[i];}
- \DoxyCodeLine{57 \}}
- \DoxyCodeLine{58 \textcolor{keywordflow}{return} d;}
- \DoxyCodeLine{59 \}}
- \DoxyCodeLine{60 }
- \DoxyCodeLine{61 \textcolor{keyword}{template}<>}
- \DoxyCodeLine{62 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}}
- \DoxyCodeLine{63 \mbox{\hyperlink{namespace_layer_a1cc1cac69c2c7e23cd745cdaaa900265}{activation\_map<Sigmoid>}}(\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} x)\{}
- \DoxyCodeLine{64 \textcolor{keywordflow}{return} 1.0/(1.0+\mbox{\hyperlink{namespace_math_a7e8411f9880b87ade916aee8531d0c11}{exp}}(-\/x));}
- \DoxyCodeLine{65 \}}
- \DoxyCodeLine{66 }
- \DoxyCodeLine{67 \textcolor{keyword}{template}<>}
- \DoxyCodeLine{68 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}}
- \DoxyCodeLine{69 \mbox{\hyperlink{namespace_layer_a2a722f834e422b77ee155b2bd252c995}{activation\_diff\_map<Sigmoid>}}(\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} x)\{}
- \DoxyCodeLine{70 \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} t=\mbox{\hyperlink{namespace_layer_a1cc1cac69c2c7e23cd745cdaaa900265}{activation\_map<Sigmoid>}}(x);}
- \DoxyCodeLine{71 \textcolor{keywordflow}{return} t*(1.0-\/t);}
- \DoxyCodeLine{72 \}}
- \DoxyCodeLine{73 \}}
- \DoxyCodeLine{74 \textcolor{preprocessor}{\#endif}}
- \end{DoxyCode}
|