提交 a085da4c authored 作者: Frederic Bastien's avatar Frederic Bastien

update Theano section

上级 6da87579
...@@ -21,6 +21,8 @@ Département d'Informatique et de Recherche Opérationnelle \newline ...@@ -21,6 +21,8 @@ Département d'Informatique et de Recherche Opérationnelle \newline
Université de Montréal \newline Université de Montréal \newline
Montréal, Canada \newline Montréal, Canada \newline
\texttt{bastienf@iro.umontreal.ca} \newline \newline \texttt{bastienf@iro.umontreal.ca} \newline \newline
Presentation prepared with Pierre-Luc Carrier, KyungHyun Cho and \newline
Çağlar Gülçehre
} }
\date{Next.ML 2015} \date{Next.ML 2015}
...@@ -40,8 +42,6 @@ Montréal, Canada \newline ...@@ -40,8 +42,6 @@ Montréal, Canada \newline
\begin{frame} \begin{frame}
\frametitle{Task} \frametitle{Task}
LSTM Networks for Sentiment Analysis
This is a classification task where we need to tell if the review was This is a classification task where we need to tell if the review was
positive or negative. positive or negative.
...@@ -61,7 +61,7 @@ We use the IMDB dataset. ...@@ -61,7 +61,7 @@ We use the IMDB dataset.
\item SciPy: sparse matrix objects and more scientific computing functionality \item SciPy: sparse matrix objects and more scientific computing functionality
\item libgpuarray: GPU $n$-dimensional array object in C for CUDA and OpenCL \item libgpuarray: GPU $n$-dimensional array object in C for CUDA and OpenCL
\item Theano: compiler/symbolic graph manipulation \item Theano: compiler/symbolic graph manipulation
\item Pylearn2: machine learning framework \item Pylearn2: machine learning framework for researchers
\end{itemize} \end{itemize}
\end{frame} \end{frame}
...@@ -145,42 +145,8 @@ We use the IMDB dataset. ...@@ -145,42 +145,8 @@ We use the IMDB dataset.
\end{frame} \end{frame}
\begin{frame}{Description} \begin{frame}{Description}
TODO, merge with next slides
\begin{itemize}
\item Mathematical symbolic expression compiler
\item Expressions mimic NumPy's syntax and semantics
\item Dynamic C/CUDA code generation
\begin{itemize}
\item C/C++, CUDA, OpenCL, PyCUDA, Cython, Numba, \ldots
\end{itemize}
\item Efficient symbolic differentiation
%\begin{itemize}
% \item Derivatives of functions with one or many inputs.
% \item Computation of the Jacobian, Hessian, R and L op.
%\end{itemize}
\item Speed and stability optimizations
\begin{itemize}
\item Gives the right answer for ``$\log (1 + x)$'' even if $x$ is really tiny.
\end{itemize}
\item Extensive unit-testing and self-verification
%\begin{itemize}
% \item Detects and diagnoses many types of errors
%\end{itemize}
\item Works on Linux, OS X and Windows
\item Transparent use of a GPU
\begin{itemize}
\item {\tt float32} only for now (libgpuarray provides much more)
\item Limited support on Windows
\end{itemize}
% \item Statically typed and purely functional
\item Sparse operations (CPU only)
\end{itemize}
\end{frame}
\begin{frame}{Theano}
High-level domain-specific language tailored to numeric computation. High-level domain-specific language for numeric computation.
\begin{itemize} \begin{itemize}
\item Syntax as close to NumPy as possible \item Syntax as close to NumPy as possible
...@@ -195,10 +161,12 @@ TODO, merge with next slides ...@@ -195,10 +161,12 @@ TODO, merge with next slides
\item Automatic speed and stability optimizations \item Automatic speed and stability optimizations
\item Can reuse other technologies for best performance. \item Can reuse other technologies for best performance.
\begin{itemize} \begin{itemize}
\item BLAS, SciPy, Cython, Numba, PyCUDA, CUDA \item BLAS, SciPy, Cython, Numba, PyCUDA, CUDA, ...
\end{itemize} \end{itemize}
\item Automatic differentiation and R op \item Automatic differentiation and R op
\item Sparse matrices \item Sparse matrices (CPU only)
\item Extensive unit-testing and self-verification
\item Works on Linux, OS X and Windows
\end{itemize} \end{itemize}
\end{frame} \end{frame}
...@@ -240,14 +208,14 @@ TODO, merge with next slides ...@@ -240,14 +208,14 @@ TODO, merge with next slides
\end{frame} \end{frame}
\begin{frame}{Overview of Library} %% \begin{frame}{Overview of Library}
Theano is many things %% Theano is many things
\begin{itemize} %% \begin{itemize}
\item Language %% \item Language
\item Compiler %% \item Compiler
\item Python library %% \item Python library
\end{itemize} %% \end{itemize}
\end{frame} %% \end{frame}
\begin{frame}{Overview Language} \begin{frame}{Overview Language}
\begin{itemize} \begin{itemize}
...@@ -255,6 +223,9 @@ TODO, merge with next slides ...@@ -255,6 +223,9 @@ TODO, merge with next slides
\item Linear algebra \item Linear algebra
\item Element-wise nonlinearities \item Element-wise nonlinearities
\item Convolution \item Convolution
\item Indexing, slicing and advanced indexing.
\item Reduction
\item Dimshuffle (n-dim transpose)
\item Extensible \item Extensible
\end{itemize} \end{itemize}
\end{frame} \end{frame}
...@@ -288,24 +259,11 @@ int f(int x, int y){ ...@@ -288,24 +259,11 @@ int f(int x, int y){
\end{itemize} \end{itemize}
\end{frame} \end{frame}
\subsection{Building}
\begin{frame}{Building expressions}
\begin{itemize}
\item Scalars
\item Vectors
\item Matrices
\item Tensors
\item Reduction
\item Dimshuffle
\end{itemize}
\end{frame}
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Scalar math} \frametitle{Scalar math}
Using Theano: Using Theano:
\begin{itemize} \begin{itemize}
\item define expression $f(x,y) = x + y$ \item define SYMBOLIC expression $f(x,y) = x + y$
\item compile expression \item compile expression
\end{itemize} \end{itemize}
\lstset{language=Python, \lstset{language=Python,
...@@ -340,7 +298,7 @@ y = T.vector() ...@@ -340,7 +298,7 @@ y = T.vector()
a = x * y a = x * y
# Vector dot product # Vector dot product
b = T.dot(x, y) b = T.dot(x, y)
# Broadcasting # Broadcasting (as NumPy, very powerful)
c = a + b c = a + b
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
...@@ -368,15 +326,10 @@ c = T.dot(x, a) ...@@ -368,15 +326,10 @@ c = T.dot(x, a)
\frametitle{Tensors} \frametitle{Tensors}
Using Theano: Using Theano:
\begin{itemize} \begin{itemize}
\item define expression $f(x,y) = x + y$ \item Dimensionality defined by length of ``broadcastable'' argument
\item compile expression \item Can add (or do other elemwise op) on two
\begin{itemize} tensors with same dimensionality
\item Dimensionality defined by length of ``broadcastable'' argument \item Duplicate tensors along broadcastable axes to make size match
\item Can add (or do other elemwise op) on two
tensors with same dimensionality
\item Duplicate tensors along broadcastable axes to
make size match
\end{itemize}
\end{itemize} \end{itemize}
\lstset{language=Python, \lstset{language=Python,
commentstyle=\itshape\color{blue}, commentstyle=\itshape\color{blue},
...@@ -393,11 +346,6 @@ x = T.tensor3() ...@@ -393,11 +346,6 @@ x = T.tensor3()
\begin{frame}[fragile] \begin{frame}[fragile]
\frametitle{Reductions} \frametitle{Reductions}
Using Theano:
\begin{itemize}
\item define expression $f(x,y) = x + y$
\item compile expression
\end{itemize}
\lstset{language=Python, \lstset{language=Python,
commentstyle=\itshape\color{blue}, commentstyle=\itshape\color{blue},
stringstyle=\color{violet}, stringstyle=\color{violet},
...@@ -423,7 +371,8 @@ mx = x.max(axis=1) ...@@ -423,7 +371,8 @@ mx = x.max(axis=1)
} }
\begin{lstlisting} \begin{lstlisting}
from theano import tensor as T from theano import tensor as T
tensor3 = T.TensorType(broadcastable=(False, False, False), dtype=''float32'') tensor3 = T.TensorType(
broadcastable=(False, False, False))
x = tensor3() x = tensor3()
y = x.dimshuffle((2, 1, 0)) y = x.dimshuffle((2, 1, 0))
a = T.matrix() a = T.matrix()
...@@ -436,24 +385,27 @@ e = a + d ...@@ -436,24 +385,27 @@ e = a + d
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
\begin{frame} \begin{frame}[fragile]
\frametitle{Indexing} \frametitle{Indexing}
As NumPy! As NumPy!
This mean all slices, index selection return view
\begin{itemize} \lstset{language=Python,
\item This mean all slices, index selection return view: commentstyle=\itshape\color{blue},
\begin{itemize} stringstyle=\color{violet},
\item a\_tensor[startstopstep, N] \# return a view }
\item a\_tensor[-1] \# reverse the vector, return a view \begin{lstlisting}
\end{itemize} # return views
\item Advanced indexing as NumPy: a_tensor[int]
\begin{itemize} a_tensor[int, int]
\item This mean it can use vector/tensor of indices to use. a_tensor[start:stop:step, start:stop:step]
\item this create a copy a_tensor[::-1] # reverse the first dimension
\item This can be mixed with slicing/index selection.
\item GPU Support only this case: a\_tensor[an\_index\_vector] # Advanced indexing, return copy
\end{itemize} a_tensor[an_index_vector] # Supported on GPU.
\end{itemize} a_tensor[an_index_vector, an_index_vector]
a_tensor[int, an_index_vector]
a_tensor[an_index_tensor, ...]
\end{lstlisting}
\end{frame} \end{frame}
\subsection{Compiling/Running} \subsection{Compiling/Running}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论