Net definition section finished
This commit is contained in:
parent
4b80e7391f
commit
b061fd5a2f
17 changed files with 221 additions and 56 deletions
|
|
@ -1,3 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{batch}\PYGZbs{}\PYG{n}{\PYGZus{}size}
|
||||
\PYG{n}{nn}\PYG{o}{.}\PYG{n}{Module}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{x} \PYG{o}{=} \PYG{n}{x} \PYG{o}{*} \PYG{l+m+mi}{2}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{F}\PYG{o}{.}\PYG{n}{log\PYGZus{}softmax}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{fc1}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{fc0}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{forward}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{p}{,} \PYG{n}{x}\PYG{p}{)}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{fc2}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{k}{class} \PYG{n+nc}{Net}\PYG{p}{(}\PYG{n}{nn}\PYG{o}{.}\PYG{n}{Module}\PYG{p}{):}
|
||||
\PYG{k}{def} \PYG{n+nf+fm}{\PYGZus{}\PYGZus{}init\PYGZus{}\PYGZus{}}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{p}{):}
|
||||
\PYG{n+nb}{super}\PYG{p}{()}\PYG{o}{.}\PYG{n+nf+fm}{\PYGZus{}\PYGZus{}init\PYGZus{}\PYGZus{}}\PYG{p}{()}
|
||||
\PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc0} \PYG{o}{=} \PYG{n}{nn}\PYG{o}{.}\PYG{n}{Linear}\PYG{p}{(}\PYG{l+m+mi}{28} \PYG{o}{*} \PYG{l+m+mi}{28}\PYG{p}{,} \PYG{l+m+mi}{64}\PYG{p}{)}
|
||||
\PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc1} \PYG{o}{=} \PYG{n}{nn}\PYG{o}{.}\PYG{n}{Linear}\PYG{p}{(}\PYG{l+m+mi}{64}\PYG{p}{,} \PYG{l+m+mi}{120}\PYG{p}{)}
|
||||
\PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc2} \PYG{o}{=} \PYG{n}{nn}\PYG{o}{.}\PYG{n}{Linear}\PYG{p}{(}\PYG{l+m+mi}{120}\PYG{p}{,} \PYG{l+m+mi}{10}\PYG{p}{)}
|
||||
|
||||
\PYG{k}{def} \PYG{n+nf}{forward}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{p}{,} \PYG{n}{x}\PYG{p}{):}
|
||||
\PYG{n}{x} \PYG{o}{=} \PYG{n}{F}\PYG{o}{.}\PYG{n}{relu}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc0}\PYG{p}{(}\PYG{n}{x}\PYG{p}{))}
|
||||
\PYG{n}{x} \PYG{o}{=} \PYG{n}{F}\PYG{o}{.}\PYG{n}{relu}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc1}\PYG{p}{(}\PYG{n}{x}\PYG{p}{))}
|
||||
\PYG{n}{x} \PYG{o}{=} \PYG{n+nb+bp}{self}\PYG{o}{.}\PYG{n}{fc2}\PYG{p}{(}\PYG{n}{x}\PYG{p}{)}
|
||||
\PYG{k}{return} \PYG{n}{F}\PYG{o}{.}\PYG{n}{log\PYGZus{}softmax}\PYG{p}{(}\PYG{n}{x}\PYG{p}{)}
|
||||
\end{Verbatim}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
\begin{Verbatim}[commandchars=\\\{\}]
|
||||
\PYG{n}{batch\PYGZus{}size}
|
||||
\end{Verbatim}
|
||||
Loading…
Add table
Add a link
Reference in a new issue