Mercurial > ift6266
view writeup/nips2010_submission.tex @ 467:e0e57270b2af
refs
author | Yoshua Bengio <bengioy@iro.umontreal.ca> |
---|---|
date | Sat, 29 May 2010 16:50:03 -0400 |
parents | 6205481bf33f |
children | d02d288257bf |
line wrap: on
line source
\documentclass{article} % For LaTeX2e \usepackage{nips10submit_e,times} \usepackage{amsthm,amsmath,amssymb,bbold,bbm} \usepackage{algorithm,algorithmic} \usepackage[utf8]{inputenc} \usepackage{graphicx,subfigure} \usepackage{mlapa} \title{Generating and Exploiting Perturbed and Multi-Task Handwritten Training Data for Deep Architectures} \author{The IFT6266 Gang} \begin{document} %\makeanontitle \maketitle \begin{abstract} Recent theoretical and empirical work in statistical machine learning has demonstrated the importance of learning algorithms for deep architectures, i.e., function classes obtained by composing multiple non-linear transformations. In the area of handwriting recognition, deep learning algorithms had been evaluated on rather small datasets with a few tens of thousands of examples. Here we propose a powerful generator of variations of examples for character images based on a pipeline of stochastic transformations that include not only the usual affine transformations but also the addition of slant, local elastic deformations, changes in thickness, background images, color, contrast, occlusion, and various types of pixel and spatially correlated noise. We evaluate a deep learning algorithm (Stacked Denoising Autoencoders) on the task of learning to classify digits and letters transformed with this pipeline, using the hundreds of millions of generated examples and testing on the full 62-class NIST test set. We find that the SDA outperforms its shallow counterpart, an ordinary Multi-Layer Perceptron, and that it is better able to take advantage of the additional generated data, as well as better able to take advantage of the multi-task setting, i.e., training from more classes than those of interest in the end. In fact, we find that the SDA reaches human performance as estimated by the Amazon Mechanical Turk on the 62-class NIST test characters. \end{abstract} \section{Introduction} Deep Learning has emerged as a promising new area of research in statistical machine learning (see~\emcite{Bengio-2009} for a review). Learning algorithms for deep architectures are centered on the learning of useful representations of data, which are better suited to the task at hand. This is in great part inspired by observations of the mammalian visual cortex, which consists of a chain of processing elements, each of which is associated with a different representation. In fact, it was found recently that the features learnt in deep architectures resemble those observed in the first two of these stages (in areas V1 and V2 of visual cortex)~\cite{HonglakL2008}. Processing images typically involves transforming the raw pixel data into new {\bf representations} that can be used for analysis or classification. For example, a principal component analysis representation linearly projects the input image into a lower-dimensional feature space. Why learn a representation? Current practice in the computer vision literature converts the raw pixels into a hand-crafted representation (e.g.\ SIFT features~\cite{Lowe04}), but deep learning algorithms tend to discover similar features in their first few levels~\cite{HonglakL2008,ranzato-08,Koray-08,VincentPLarochelleH2008-very-small}. Learning increases the ease and practicality of developing representations that are at once tailored to specific tasks, yet are able to borrow statistical strength from other related tasks (e.g., modeling different kinds of objects). Finally, learning the feature representation can lead to higher-level (more abstract, more general) features that are more robust to unanticipated sources of variance extant in real data. Whereas a deep architecture can in principle be more powerful than a shallow one in terms of representation, depth appears to render the training problem more difficult in terms of optimization and local minima. It is also only recently that successful algorithms were proposed to overcome some of these difficulties. All are based on unsupervised learning, often in an greedy layer-wise ``unsupervised pre-training'' stage~\cite{Bengio-2009}. One of these layer initialization techniques, applied here, is the Denoising Auto-Encoder~(DEA)~\cite{VincentPLarochelleH2008-very-small}, which performed similarly or better than previously proposed Restricted Boltzmann Machines in terms of unsupervised extraction of a hierarchy of features useful for classification. The principle is that each layer starting from the bottom is trained to encode their input (the output of the previous layer) and try to reconstruct it from a corrupted version of it. After this unsupervised initialization, the stack of denoising auto-encoders can be converted into a deep supervised feedforward neural network and trained by stochastic gradient descent. In this paper we ask the following questions: \begin{enumerate} \item Do the good results previously obtained with deep architectures on the MNIST digits generalize to the setting of a much larger and richer (but similar) dataset, the NIST special database 19, with 62 classes and around 800k examples? \item To what extent does the perturbation of input images (e.g. adding noise, affine transformations, background images) make the resulting classifier better not only on similarly perturbed images but also on the {\em original clean examples}? \item Do deep architectures benefit more from such {\em out-of-distribution} examples, i.e. do they benefit more from the self-taught learning~\cite{RainaR2007} framework? \item Similarly, does the feature learning step in deep learning algorithms benefit more training with similar but different classes (i.e. a multi-task learning scenario) than a corresponding shallow and purely supervised architecture? \end{enumerate} The experimental results presented here provide positive evidence towards all of these questions. \section{Perturbation and Transformation of Character Images} This section describes the different transformations we used to stochastically transform source images in order to obtain data. More details can be found in this technical report~\cite{ift6266-tr-anonymous}. The code for these transformations (mostly python) is available at {\tt http://anonymous.url.net}. All the modules in the pipeline share a global control parameter ($0 \le complexity \le 1$) that allows one to modulate the amount of deformation or noise introduced. There are two main parts in the pipeline. The first one, from slant to pinch below, performs transformations. The second part, from blur to contrast, adds different kinds of noise. {\large\bf Transformations}\\ {\bf Slant}\\ We mimic slant by shifting each row of the image proportionnaly to its height: $shift = round(slant \times height)$. The $slant$ coefficient can be negative or positive with equal probability and its value is randomly sampled according to the complexity level: e $slant \sim U[0,complexity]$, so the maximum displacement for the lowest or highest pixel line is of $round(complexity \times 32)$.\\ {\bf Thickness}\\ Morpholigical operators of dilation and erosion~\cite{Haralick87,Serra82} are applied. The neighborhood of each pixel is multiplied element-wise with a {\em structuring element} matrix. The pixel value is replaced by the maximum or the minimum of the resulting matrix, respectively for dilation or erosion. Ten different structural elements with increasing dimensions (largest is $5\times5$) were used. For each image, randomly sample the operator type (dilation or erosion) with equal probability and one structural element from a subset of the $n$ smallest structuring elements where $n$ is $round(10 \times complexity)$ for dilation and $round(6 \times complexity)$ for erosion. A neutral element is always present in the set, and if it is chosen no transformation is applied. Erosion allows only the six smallest structural elements because when the character is too thin it may be completely erased.\\ {\bf Affine Transformations}\\ A $2 \times 3$ affine transform matrix (with 6 parameters $(a,b,c,d,e,f)$) is sampled according to the $complexity$ level. Each pixel $(x,y)$ of the output image takes the value of the pixel nearest to $(ax+by+c,dx+ey+f)$ in the input image. This produces scaling, translation, rotation and shearing. The marginal distributions of $(a,b,c,d,e,f)$ have been tuned by hand to forbid important rotations (not to confuse classes) but to give good variability of the transformation: $a$ and $d$ $\sim U[1-3 \times complexity,1+3 \times complexity]$, $b$ and $e$ $\sim[-3 \times complexity,3 \times complexity]$ and $c$ and $f$ $\sim U[-4 \times complexity, 4 \times complexity]$.\\ {\bf Local Elastic Deformations}\\ This filter induces a "wiggly" effect in the image, following~\cite{SimardSP03}, which provides more details. Two "displacements" fields are generated and applied, for horizontal and vertical displacements of pixels. To generate a pixel in either field, first a value between -1 and 1 is chosen from a uniform distribution. Then all the pixels, in both fields, are multiplied by a constant $\alpha$ which controls the intensity of the displacements (larger $\alpha$ translates into larger wiggles). Each field is convoluted with a Gaussian 2D kernel of standard deviation $\sigma$. Visually, this results in a blur. $\alpha = \sqrt[3]{complexity} \times 10.0$ and $\sigma = 10 - 7 \times \sqrt[3]{complexity}$.\\ {\bf Pinch}\\ This GIMP filter is named "Whirl and pinch", but whirl was set to 0. A pinch is ``similar to projecting the image onto an elastic surface and pressing or pulling on the center of the surface''~\cite{GIMP-manual}. For a square input image, think of drawing a circle of radius $r$ around a center point $C$. Any point (pixel) $P$ belonging to that disk (region inside circle) will have its value recalculated by taking the value of another "source" pixel in the original image. The position of that source pixel is found on the line thats goes through $C$ and $P$, but at some other distance $d_2$. Define $d_1$ to be the distance between $P$ and $C$. $d_2$ is given by $d_2 = sin(\frac{\pi{}d_1}{2r})^{-pinch} \times d_1$, where $pinch$ is a parameter to the filter. The actual value is given by bilinear interpolation considering the pixels around the (non-integer) source position thus found. Here $pinch \sim U[-complexity, 0.7 \times complexity]$.\\ {\large\bf Injecting Noise}\\ {\bf Motion Blur}\\ This GIMP filter is a ``linear motion blur'' in GIMP terminology, with two parameters, $length$ and $angle$. The value of a pixel in the final image is the approximately mean value of the $length$ first pixels found by moving in the $angle$ direction. Here $angle \sim U[0,360]$ degrees, and $length \sim {\rm Normal}(0,(3 \times complexity)^2)$.\\ {\bf Occlusion}\\ This filter selects a random rectangle from an {\em occluder} character images and places it over the original {\em occluded} character image. Pixels are combined by taking the max(occluder,occluded), closer to black. The corners of the occluder The rectangle corners are sampled so that larger complexity gives larger rectangles. The destination position in the occluded image are also sampled according to a normal distribution (see more details in~\cite{ift6266-tr-anonymous}. It has has a probability of not being applied at all of 60\%.\\ {\bf Pixel Permutation}\\ This filter permutes neighbouring pixels. It selects first $\frac{complexity}{3}$ pixels randomly in the image. Each of them are then sequentially exchanged to one other pixel in its $V4$ neighbourhood. Number of exchanges to the left, right, top, bottom are equal or does not differ from more than 1 if the number of selected pixels is not a multiple of 4. It has has a probability of not being applied at all of 80\%.\\ {\bf Gaussian Noise}\\ This filter simply adds, to each pixel of the image independently, a noise $\sim Normal(0(\frac{complexity}{10})^2)$. It has has a probability of not being applied at all of 70\%.\\ {\bf Background Images}\\ Following~\cite{Larochelle-jmlr-2009}, this transformation adds a random background behind the letter. The background is chosen by first selecting, at random, an image from a set of images. Then a 32$\times$32 subregion of that image is chosen as the background image (by sampling position uniformly while making sure not to cross image borders). To combine the original letter image and the background image, contrast adjustments are made. We first get the maximal values (i.e. maximal intensity) for both the original image and the background image, $maximage$ and $maxbg$. We also have a parameter $contrast \sim U[complexity, 1]$. Each background pixel value is multiplied by $\frac{max(maximage - contrast, 0)}{maxbg}$ (higher contrast yield darker background). The output image pixels are max(background,original).\\ {\bf Salt and Pepper Noise}\\ This filter adds noise $\sim U[0,1]$ to random subsets of pixels. The number of selected pixels is $0.2 \times complexity$. This filter has a probability of not being applied at all of 75\%.\\ {\bf Spatially Gaussian Noise}\\ Different regions of the image are spatially smoothed. The image is convolved with a symmetric Gaussian kernel of size and variance choosen uniformly in the ranges $[12,12 + 20 \times complexity]$ and $[2,2 + 6 \times complexity]$. The result is normalized between $0$ and $1$. We also create a symmetric averaging window, of the kernel size, with maximum value at the center. For each image we sample uniformly from $3$ to $3 + 10 \times complexity$ pixels that will be averaging centers between the original image and the filtered one. We initialize to zero a mask matrix of the image size. For each selected pixel we add to the mask the averaging window centered to it. The final image is computed from the following element-wise operation: $\frac{image + filtered image \times mask}{mask+1}$. This filter has a probability of not being applied at all of 75\%.\\ {\bf Scratches}\\ The scratches module places line-like white patches on the image. The lines are heavily transformed images of the digit "1" (one), chosen at random among five thousands such 1 images. The 1 image is randomly cropped and rotated by an angle $\sim Normal(0,(100 \times complexity)^2$, using bicubic interpolation, Two passes of a greyscale morphological erosion filter are applied, reducing the width of the line by an amount controlled by $complexity$. This filter is only applied only 15\% of the time. When it is applied, 50\% of the time, only one patch image is generated and applied. In 30\% of cases, two patches are generated, and otherwise three patches are generated. The patch is applied by taking the maximal value on any given patch or the original image, for each of the 32x32 pixel locations.\\ {\bf Color and Contrast Changes}\\ This filter changes the constrast and may invert the image polarity (white on black to black on white). The contrast $C$ is defined here as the difference between the maximum and the minimum pixel value of the image. Contrast $\sim U[1-0.85 \times complexity,1]$ (so constrast $\geq 0.15$). The image is normalized into $[\frac{1-C}{2},1-\frac{1-C}{2}]$. The polarity is inverted with $0.5$ probability. \begin{figure}[h] \resizebox{.99\textwidth}{!}{\includegraphics{images/example_t.png}}\\ \caption{Illustration of the pipeline of stochastic transformations applied to the image of a lower-case t (the upper left image). Each image in the pipeline (going from left to right, first top line, then bottom line) shows the result of applying one of the modules in the pipeline. The last image (bottom right) is used as training example.} \label{fig:pipeline} \end{figure} \section{Experimental Setup} \subsection{Training Datasets} \subsubsection{Data Sources} \begin{itemize} \item {\bf NIST} The NIST Special Database 19 (NIST19) is a very widely used dataset for training and testing OCR systems. The dataset is composed with 8????? digits and characters (upper and lower cases), with hand checked classifications, extracted from handwritten sample forms of 3600 writers. The characters are labelled by one of the 62 classes corresponding to "0"-"9","A"-"Z" and "a"-"z". The dataset contains 8 series of different complexity. The fourth series, $hsf_4$, experimentally recognized to be the most difficult one for classification task is recommended by NIST as testing set and is used in our work for that purpose. It contains 82600 examples, while the training and validation sets (which have the same distribution) contain XXXXX and XXXXX examples respectively. The performances reported by previous work on that dataset mostly use only the digits. Here we use all the classes both in the training and testing phase. This is especially useful to estimate the effect of a multi-task setting. Note that the distribution of the classes in the NIST training and test sets differs substantially, with relatively many more digits in the test set, and uniform distribution of letters in the test set, not in the training set (more like the natural distribution of letters in text). \item {\bf Fonts} TODO!!! \item {\bf Captchas} The Captcha data source is an adaptation of the \emph{pycaptcha} library (a python based captcha generator library) for generating characters of the same format as the NIST dataset. The core of this data source is composed with a random character generator and various kinds of tranformations similar to those described in the previous sections. In order to increase the variability of the data generated, different fonts are used for generating the characters. Transformations (slant, distorsions, rotation, translation) are applied to each randomly generated character with a complexity depending on the value of the complexity parameter provided by the user of the data source. Two levels of complexity are allowed and can be controlled via an easy to use facade class. \item {\bf OCR data} \end{itemize} \subsubsection{Data Sets} \begin{itemize} \item {\bf NIST} This is the raw NIST special database 19. \item {\bf P07} The dataset P07 is sampled with our transformation pipeline with a complexity parameter of $0.7$. For each new exemple to generate, we choose one source with the following probability: $0.1$ for the fonts, $0.25$ for the captchas, $0.25$ for OCR data and $0.4$ for NIST. We apply all the transformations in their order and for each of them we sample uniformly a complexity in the range $[0,0.7]$. \item {\bf NISTP} NISTP is equivalent to P07 (complexity parameter of $0.7$ with the same sources proportion) except that we only apply transformations from slant to pinch. Therefore, the character is transformed but no additionnal noise is added to the image, giving images closer to the NIST dataset. \end{itemize} \subsection{Models and their Hyperparameters} \subsubsection{Multi-Layer Perceptrons (MLP)} An MLP is a family of functions that are described by stacking layers of of a function similar to $$g(x) = \tanh(b+Wx)$$ The input, $x$, is a $d$-dimension vector. The output, $g(x)$, is a $m$-dimension vector. The parameter $W$ is a $m\times d$ matrix and is called the weight matrix. The parameter $b$ is a $m$-vector and is called the bias vector. The non-linearity (here $\tanh$) is applied element-wise to the output vector. Usually the input is referred to a input layer and similarly for the output. You can of course chain several such functions to obtain a more complex one. Here is a common example $$f(x) = c + V\tanh(b+Wx)$$ In this case the intermediate layer corresponding to $\tanh(b+Wx)$ is called a hidden layer. Here the output layer does not have the same non-linearity as the hidden layer. This is a common case where some specialized non-linearity is applied to the output layer only depending on the task at hand. If you put 3 or more hidden layers in such a network you obtain what is called a deep MLP. The parameters to adapt are the weight matrix and the bias vector for each layer. \subsubsection{Stacked Denoising Auto-Encoders (SDAE)} \label{SdA} Auto-encoders are essentially a way to initialize the weights of the network to enable better generalization. This is essentially unsupervised training where the layer is made to reconstruct its input through and encoding and decoding phase. Denoising auto-encoders are a variant where the input is corrupted with random noise but the target is the uncorrupted input. The principle behind these initialization methods is that the network will learn the inherent relation between portions of the data and be able to represent them thus helping with whatever task we want to perform. An auto-encoder unit is formed of two MLP layers with the bottom one called the encoding layer and the top one the decoding layer. Usually the top and bottom weight matrices are the transpose of each other and are fixed this way. The network is trained as such and, when sufficiently trained, the MLP layer is initialized with the parameters of the encoding layer. The other parameters are discarded. The stacked version is an adaptation to deep MLPs where you initialize each layer with a denoising auto-encoder starting from the bottom. During the initialization, which is usually called pre-training, the bottom layer is treated as if it were an isolated auto-encoder. The second and following layers receive the same treatment except that they take as input the encoded version of the data that has gone through the layers before it. For additional details see \cite{vincent:icml08}. \section{Experimental Results} \subsection{SDA vs MLP vs Humans} We compare here the best MLP (according to validation set error) that we found against the best SDA (again according to validation set error), along with a precise estimate of human performance obtained via Amazon's Mechanical Turk (AMT) service\footnote{http://mturk.com}. AMT users are paid small amounts of money to perform tasks for which human intelligence is required. Mechanical Turk has been used extensively in natural language processing \cite{SnowEtAl2008} and vision \cite{SorokinAndForsyth2008,whitehill09}. AMT users where presented with 10 character images and asked to type 10 corresponding ascii characters. Hence they were forced to make a hard choice among the 62 character classes. Three users classified each image, allowing to estimate inter-human variability (shown as +/- in parenthesis below). \begin{table} \caption{Overall comparison of error rates ($\pm$ std.err.) on 62 character classes (10 digits + 26 lower + 26 upper), except for last columns -- digits only, between deep architecture with pre-training (SDA=Stacked Denoising Autoencoder) and ordinary shallow architecture (MLP=Multi-Layer Perceptron). The models shown are all trained using perturbed data (NISTP or P07) and using a validation set to select hyper-parameters and other training choices. \{SDA,MLP\}0 are trained on NIST, \{SDA,MLP\}1 are trained on NISTP, and \{SDA,MLP\}2 are trained on P07. The human error rate on digits is a lower bound because it does not count digits that were recognized as letters. For comparison, the results found in the literature on NIST digits classification using the same test set are included.} \label{tab:sda-vs-mlp-vs-humans} \begin{center} \begin{tabular}{|l|r|r|r|r|} \hline & NIST test & NISTP test & P07 test & NIST test digits \\ \hline Humans& 18.2\% $\pm$.1\% & 39.4\%$\pm$.1\% & 46.9\%$\pm$.1\% & $>1.1\%$ \\ \hline SDA0 & 23.7\% $\pm$.14\% & 65.2\%$\pm$.34\% & 97.45\%$\pm$.06\% & 2.7\% $\pm$.14\%\\ \hline SDA1 & 17.1\% $\pm$.13\% & 29.7\%$\pm$.3\% & 29.7\%$\pm$.3\% & 1.4\% $\pm$.1\%\\ \hline SDA2 & 18.7\% $\pm$.13\% & 33.6\%$\pm$.3\% & 39.9\%$\pm$.17\% & 1.7\% $\pm$.1\%\\ \hline MLP0 & 24.2\% $\pm$.15\% & 68.8\%$\pm$.33\% & 78.70\%$\pm$.14\% & 3.45\% $\pm$.15\% \\ \hline MLP1 & 23.0\% $\pm$.15\% & 41.8\%$\pm$.35\% & 90.4\%$\pm$.1\% & 3.85\% $\pm$.16\% \\ \hline MLP2 & 24.3\% $\pm$.15\% & 46.0\%$\pm$.35\% & 54.7\%$\pm$.17\% & 4.85\% $\pm$.18\% \\ \hline \cite{Granger+al-2007} & & & & 4.95\% $\pm$.18\% \\ \hline \cite{Cortes+al-2000} & & & & 3.71\% $\pm$.16\% \\ \hline \cite{Oliveira+al-2002} & & & & 2.4\% $\pm$.13\% \\ \hline \cite{Migram+al-2005} & & & & 2.1\% $\pm$.12\% \\ \hline \end{tabular} \end{center} \end{table} \subsection{Perturbed Training Data More Helpful for SDAE} \begin{table} \caption{Relative change in error rates due to the use of perturbed training data, either using NISTP, for the MLP1/SDA1 models, or using P07, for the MLP2/SDA2 models. A positive value indicates that training on the perturbed data helped for the given test set (the first 3 columns on the 62-class tasks and the last one is on the clean 10-class digits). Clearly, the deep learning models did benefit more from perturbed training data, even when testing on clean data, whereas the MLP trained on perturbed data performed worse on the clean digits and about the same on the clean characters. } \label{tab:sda-vs-mlp-vs-humans} \begin{center} \begin{tabular}{|l|r|r|r|r|} \hline & NIST test & NISTP test & P07 test & NIST test digits \\ \hline SDA0/SDA1-1 & 38\% & 84\% & 228\% & 93\% \\ \hline SDA0/SDA2-1 & 27\% & 94\% & 144\% & 59\% \\ \hline MLP0/MLP1-1 & 5.2\% & 65\% & -13\% & -10\% \\ \hline MLP0/MLP2-1 & -0.4\% & 49\% & 44\% & -29\% \\ \hline \end{tabular} \end{center} \end{table} \subsection{Multi-Task Learning Effects} As previously seen, the SDA is better able to benefit from the transformations applied to the data than the MLP. In this experiment we define three tasks: recognizing digits (knowing that the input is a digit), recognizing upper case characters (knowing that the input is one), and recognizing lower case characters (knowing that the input is one). We consider the digit classification task as the target task and we want to evaluate whether training with the other tasks can help or hurt, and whether the effect is different for MLPs versus SDAs. The goal is to find out if deep learning can benefit more (or less) from multiple related tasks (i.e. the multi-task setting) compared to a corresponding purely supervised shallow learner. We use a single hidden layer MLP with 1000 hidden units, and a SDA with 3 hidden layers (1000 hidden units per layer), pre-trained and fine-tuned on NIST. Our results show that the MLP benefits marginally from the multi-task setting in the case of digits (5\% relative improvement) but is actually hurt in the case of characters (respectively 3\% and 4\% worse for lower and upper class characters). On the other hand the SDA benefitted from the multi-task setting, with relative error rate improvements of 27\%, 15\% and 13\% respectively for digits, lower and upper case characters, as shown in Table~\ref{tab:multi-task}. \begin{table} \caption{Test error rates and relative change in error rates due to the use of a multi-task setting, i.e., training on each task in isolation vs training for all three tasks together, for MLPs vs SDAs. The SDA benefits much more from the multi-task setting. All experiments on only on the unperturbed NIST data, using validation error for model selection. Relative improvement is 1 - single-task error / multi-task error.} \label{tab:multi-task} \begin{center} \begin{tabular}{|l|r|r|r|} \hline & single-task & multi-task & relative \\ & setting & setting & improvement \\ \hline MLP-digits & 3.77\% & 3.99\% & 5.6\% \\ \hline MLP-lower & 17.4\% & 16.8\% & -4.1\% \\ \hline MLP-upper & 7.84\% & 7.54\% & -3.6\% \\ \hline SDA-digits & 2.6\% & 3.56\% & 27\% \\ \hline SDA-lower & 12.3\% & 14.4\% & 15\% \\ \hline SDA-upper & 5.93\% & 6.78\% & 13\% \\ \hline \end{tabular} \end{center} \end{table} \section{Conclusions} \bibliography{strings,ml,aigaion,specials} \bibliographystyle{mlapa} %\bibliographystyle{apalike} \end{document}