Mercurial > ift6266
view writeup/techreport.tex @ 419:c91d7b67fa41
Correction d'une petite erreur dans le nom des fichiers de parametres de pretrain
author | SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca> |
---|---|
date | Fri, 30 Apr 2010 14:48:08 -0400 |
parents | 0282882aa91f |
children | a3a4a9c6476d e7790db265b1 |
line wrap: on
line source
\documentclass[12pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{times} \usepackage{mlapa} \begin{document} \title{Generating and Exploiting Perturbed Training Data for Deep Architectures} \author{The IFT6266 Gang} \date{April 2010, Technical Report, Dept. IRO, U. Montreal} \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 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. \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. \section{Perturbation and Transformation of Character Images} \subsection{Adding Slant} In order to mimic a slant effect, we simply shift each row of the image proportionnaly to its height. The coefficient is randomly sampled according to the complexity level and can be negatif or positif with equal probability. \subsection{Changing Thickness} To change the thickness of the characters we used morpholigical operators: dilation and erosion~\cite{Haralick87,Serra82}. The basic idea of such transform is, for each pixel, to multiply in the element-wise manner its neighbourhood with a matrix called the structuring element. Then for dilation we remplace the pixel value by the maximum of the result, or the minimum for erosion. This will dilate or erode objects in the image, the strength of the transform only depends on the structuring element. We used ten different structural elements with various shapes (the biggest is $5\times5$). for each image, we radomly sample the operator type (dilation or erosion) and one structural element from a subset depending of the complexity (the higher the complexity, the biggest the structural element can be). Erosion allows only the five smallest structural elements because when the character is too thin it may erase it completly. \subsection{Affine Transformations} We generate an affine transform matrix according to the complexity level, then we apply it directly to the image. This allows to produce scaling, translation, rotation and shearing variances. We took care that the maximum rotation applied to the image is low enough not to confuse classes. \subsection{Local Elastic Deformations} This filter induces a "wiggly" effect in the image. The description here will be brief, as the algorithm follows precisely what is described in \cite{SimardSP03}. The general idea is to generate two "displacements" fields, for horizontal and vertical displacements of pixels. Each of these fields has the same size as the original image. When generating the transformed image, we'll loop over the x and y positions in the fields and select, as a value, the value of the pixel in the original image at the (relative) position given by the displacement fields for this x and y. If the position we'd retrieve is outside the borders of the image, we use a 0 value instead. 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, is multiplied by a constant $\alpha$ which controls the intensity of the displacements (bigger $\alpha$ translates into larger wiggles). As a final step, each field is convoluted with a Gaussian 2D kernel of standard deviation $\sigma$. Visually, this results in a "blur" filter. This has the effect of making values next to each other in the displacement fields similar. In effect, this makes the wiggles more coherent, less noisy. As displacement fields were long to compute, 50 pairs of fields were generated per complexity in increments of 0.1 (50 pairs for 0.1, 50 pairs for 0.2, etc.), and afterwards, given a complexity, we selected randomly among the 50 corresponding pairs. $\sigma$ and $\alpha$ were linked to complexity through the formulas $\alpha = \sqrt[3]{complexity} \times 10.0$ and $\sigma = 10 - 7 \times \sqrt[3]{complexity}$. \subsection{Motion Blur} This is a GIMP filter we applied, a "linear motion blur" in GIMP terminology. The description will be brief as it is a well-known filter. This algorithm has two input parameters, $length$ and $angle$. The value of a pixel in the final image is the mean value of the $length$ first pixels found by moving in the $angle$ direction. An approximation of this idea is used, as we won't fall onto precise pixels by following that direction. This is done using the Bresenham line algorithm. The angle, in our case, is chosen from a uniform distribution over $[0,360]$ degrees. The length, though, depends on the complexity; it's sampled from a Gaussian distribution of mean 0 and standard deviation $\sigma = 3 \times complexity$. \subsection{Pinch} This is another GIMP filter we used. The filter is in fact named "Whirl and pinch", but we don't use the "whirl" part (whirl is set to 0). As described in GIMP, a pinch is "similar to projecting the image onto an elastic surface and pressing or pulling on the center of the surface". Mathematically, 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. If the region considered is not square then, before computing $d_2$, the smallest dimension (x or y) is stretched such that we may consider the region as if it was square. Then, after $d_2$ has been computed and corresponding components $d_2\_x$ and $d_2\_y$ have been found, the component corresponding to the stretched dimension is compressed back by an inverse ratio. The actual value is given by bilinear interpolation considering the pixels around the (non-integer) source position thus found. The value for $pinch$ in our case was given by sampling from an uniform distribution over the range $[-complexity, 0.7 \times complexity]$. \subsection{Occlusion} This filter selects random parts of other (hereafter "occlusive") letter images and places them over the original letter (hereafter "occluded") image. To be more precise, having selected a subregion of the occlusive image and a desination position in the occluded image, to determine the final value for a given overlapping pixel, it selects whichever pixel is the lightest. As a reminder, the background value is 0, black, so the value nearest to 1 is selected. To select a subpart of the occlusive image, four numbers are generated. For compability with the code, we'll call them "haut", "bas", "gauche" and "droite" (respectively meaning top, bottom, left and right). Each of these numbers is selected according to a Gaussian distribution of mean $8 \times complexity$ and standard deviation $2$. This means the largest the complexity is, the biggest the occlusion will be. The absolute value is taken, as the numbers must be positive, and the maximum value is capped at 15. These four sizes collectively define a window centered on the middle pixel of the occlusive image. This is the part that will be extracted as the occlusion. The next step is to select a destination position in the occluded image. Vertical and horizontal displacements $y\_arrivee$ and $x\_arrivee$ are selected according to Gaussian distributions of mean 0 and of standard deviations of, respectively, 3 and 2. Then an horizontal placement mode, $endroit$ (meaning location), is selected to be of three values meaning left, middle or right. If $endroit$ is "middle", the occlusion will be horizontally centered around the horizontal middle of the occluded image, then shifted according to $x\_arrivee$. If $endroit$ is "left", it will be placed on the left of the occluded image, then displaced right according to $x\_arrivee$. The contrary happens if $endroit$ is $right$. In both the horizontal and vertical positionning, the maximum position in either direction is such that the selected occlusion won't go beyond the borders of the occluded image. This filter has a probability of not being applied, at all, of 60\%. \subsection{Background Images} 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 we choose a 32x32 subregion of that image as the background image (by sampling x and y positions 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$, given by sampling from a uniform distribution over $[complexity, 1]$. Once we have all these numbers, we first adjust the values for the background image. Each pixel value is multiplied by $\frac{max(maximage - contrast, 0)}{maxbg}$. Therefore the higher the contrast, the darkest the background will be. The final image is found by taking the brightest (i.e. value nearest to 1) pixel from either the background image or the corresponding pixel in the original image. \subsection{Salt and Pepper Noise} This filter adds noise to the image by randomly selecting a certain number of them and, for those selected pixels, assign a random value according to a uniform distribution over the $[0,1]$ ranges. This last distribution does not change according to complexity. Instead, the number of selected pixels does: the proportion of changed pixels corresponds to $complexity / 5$, which means, as a maximum, 20\% of the pixels will be randomized. On the lowest extreme, no pixel is changed. This filter also has a probability of not being applied, at all, of 25\%. \subsection{Spatially Gaussian Noise} \subsection{Color and Contrast Changes} \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{Learning Algorithms for Deep Architectures} \section{Experimental Setup} \subsection{Training Datasets} \subsubsection{Data Sources} \begin{itemize} \item {\bf NIST} \item {\bf Fonts} \item {\bf Captchas} \item {\bf OCR data} \end{itemize} \subsubsection{Data Sets} \begin{itemize} \item {\bf NIST} \item {\bf P07} \item {\bf NISTP} {\em ne pas utiliser PNIST mais NISTP, pour rester politically correct...} \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)} Auto-encoders are essentially a way to initialize the weights of the network to enable better generalization. Denoising auto-encoders are a variant where the input is corrupted with random noise before trying to repair it. 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} \begin{center} \begin{tabular}{lcc} & train w/ & train w/ \\ & NIST & P07 + NIST \\ \hline SDA & & \\ \hline MLP & & \\ \hline \end{tabular} \end{center} \subsection{Perturbed Training Data More Helpful for SDAE} \subsection{Training with More Classes than Necessary} \section{Conclusions} \bibliography{strings,ml,aigaion,specials} \bibliographystyle{mlapa} \end{document}