









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










A neural network is a function from continuous inputs to continuous outputs.
Standardization of Continuous Inputs For continuous inputs one thing to consider is to standardize the data to values from a distribution with zero mean and unit variance. For feature j, and n data examples, then we calculate
μj =
n
i∈D
xij (1)
σ^2 j =
n − 1
i∈D
(xij − μj )^2 (2)
and convert value xij (the jth feature value on instance i in the training data) to ˆxij = (xij − μj )/σj. The parameters (μj , σj ) are computed on the training set (only), with the same adjustment then made to data in any validation or test sets. Careful: whereas in describing the training of NNs with back-prop we in- dexed the input layer with i (and thus the features) and the hidden layer j, in describing the above the standard convention of i to index a labeled instance and j the feature is adopted. One reason to standardize the inputs is to allow for uniform learning of suitable weights across different inputs (so that one weight does need a priori to be significantly different in magnitude than another weight). Another reason is to avoid the problem of “stuck units,” which can occur when the sigmoid activation values get too close to 0 or 1, which occurs when the weighted input to a unit gets too small or too large. For a sigmoid, the derivative g′(in) = g(in)(1 − g(in)) = a(1 − a) for activation value a, and approaches zero as a approaches 0 or 1. The learning process is then very slow, and units can get “stuck.” Standardization of data, coupled with setting small initial weights (randomly perturbed around zero) helps to avoid this problem.
If you want to use a neural network for representing discrete functions, you have to find a way to encode the discrete inputs or outputs. There are several possible encoding methods.
Input Encodings We discuss input encodings first. The considerations are just slightly different for output encodings. One method for encoding a discrete attribute is to use a local encoding, where a single unit is used to represent the different possible values of a discrete attribute. Each discrete value is simply mapped to a real number. Another idea for encoding a discrete attribute is to use a distributed en- coding, where there is a separate unit corresponding to each possible value of the discrete attribute. In representing that a discrete attribute takes on the kth value in its set, e.g. Xk = {red , yellow , green} and xk = red and so the 1st value, the input unit corresponding to the kth value will have value 1, while other units will have value 0 or -1. In addition to being a distributed encoding, this particular approach is referred to as a “1-out-of-K” encoding. Another kind of distributed encoding is a binary encoding, in which the different possible discrete values are represented as binary numbers. In this encoding, the number of units used to represent an attribute with K possible values will be dlog 2 Ke; e.g. 2 in the example above. A value k is represented by taking the binary representation of k, and setting the values of the units according to the values of the bits in the binary representation; e.g. 00, 01 , 10 in the example above. In choosing which encoding to use, the main question to consider is: how well does the encoding represent the quantity being measured as the inputs and outputs vary continuously? The principle is that data elements with similar characteristics should be close together in the input space. For example, suppose the possible attribute values are 0 to 9. If these classes represent the “inflation rate” then a local encoding is quite appropriate, because the classifications fall on a linear scale and have a natural ordering. Value 5 is between value 4 and 6 and more similar to 4 and 6 than to other values. In this case this is an ordinal variable. Movie ratings (1 to 5 stars) is another example of an ordinal variable. A local encoding is appropriate for ordinal variables. On the other hand, if these discrete values represent the values of a categor- ical variable such as a digit, a color, a type of residence, or a favorite restaurant style, then a local encoding is usually inappropriate. For digits, we can see that the digit 8 is not visually between the digits 7 and 9 and is not closer to 7 and 9 in this sense than it is to another digit. The one exception is for a binary categorical variable, which can be easily encoded as the value of a single unit, set to -1 for False and 1 for True. For periodic data, such as the time of day or the day of the week, a local encoding is again appropriate but the difference is that the highest and lowest values are now adjacent (e.g. for days of the week {M, T, W, R, F, Sa, Su},
idea would be to select the binary encoding that is closest (for some distance metric) to the binary encoding represented by the activation levels. For a distributed encoding, with multiple output units, each representing one possible class, the issue is a little more subtle. A standard approach is to simply choose the output unit with the highest activation level as the classification, no matter what the actual activation levels. So if all the outputs are 0.85, 0.15 and 0.6 then the class corresponding to the first output unit will be chosen. An alternative is to require that there be one output unit with high activation and all the rest are low in order to classify. All other situations are considered ambiguous, and no classification is given. For example, a threshold τ > 0 can be adopted and it required that ak > τ for some output unit k and ak′ < τ for all other output units k′. The idea is that there should be significant evidence for one particular class and insufficient evidence to support other classes. For τ = 0 .5 the response in our example would be “don’t know.” We see that distributed encodings are helpful, then, in that they provide a notion of “confidence” in the classification.
2 Preprocessing the Data
In addition to standardization of the data (see above), two other issues that often arise when training NNs (and also in other ML settings) are:
Handling Missing Values. How to handle instances x where some attributes xj are missing and assigned a “null” value? In this case we can do one of the following things:
Feature Extraction. It is often necessary to reduce the dimensionality of input data. For example, this can be helpful in avoiding learning spurious patterns while training a NN, and also in being able to learn with less data. Feature extraction can sometimes be done by hand; e.g., taking data that is some measurement of a physical process (e.g., temperature) at each 1/128th of a second and converting this data into a lower dimensional representation in the frequency domain. Similarly, we might think to group together attribute values representing the specific occupation of a person into a type of occupation (e.g. “finance” in place of “accountancy, finance, banking, insurance.”) Another approach to feature extraction is Principal Component Anal- ysis (PCA). This is a powerful technique for projecting high dimensional data down to a representation on a lower dimension, by looking for a subspace of the feature space such that an “orthogonal pro- jection” of the data onto the subspace maximizes the variance of the projected points. The exact details of the PCA method are outside the scope of the course but the approach is both standard and powerful. A helpful way to think about PCA is that by selecting a subspace to project onto that maximizes the variance on the projected data, a lot of information is still provided by specifying the position of the data in the subspace, and so this remains a relevant subspace for distinguishing between the data. In an extreme case that we’re classifying cats and dogs and the subspace is “number of legs” then this would likely be a very bad choice. The projection loses all the information in the input.
3 Practical Issues
(^1) Some practical aspects of training neural networks are
on output unit 1 and thus class c 1 ∈ Y , ˆa 1 , as
z 1 =
a 1 Pr(c 1 ) Pr′(c 1 )
z 2 = (1 − a 1 ) Pr(c 2 ) Pr′(c 2 )
ˆa 1 =
z 1 z 1 + z 2
where a 1 is the output weight on the first output unit, representing class c 1 ∈ Y , values Pr(c 1 ) and Pr(c 2 ) are the marginal probability that the label on a data point is c 1 or c 2 in the domain, and Pr′(c 1 ) and Pr′(c 2 ) is the marginal probability of labels c 1 and c 2 used during training, where the data set was rebalanced. One can check that in the special case in which the training set is balanced, then we have
ˆak ∝ ak Pr(ck), (7)
and the reweighting depends on whether or not the data in the do- main is also balanced; where ∝ is the “proportional to” symbol. For example, if Pr(c 1 ) = 0. 05 , Pr(c 2 ) = 0.95, and we trained on balanced data (with Pr′(c 1 ) = Pr′(c 2 ) = 0.5), and a 1 = 0.8, then
aˆ 1 =
= 0. 174 < ˆa 2 , (8)
and we would not classify the example as class 1, but rather class 2, due to the strength of the prior on the domain.
4 Overfitting with Neural Networks
In addition to problems with using gradient descent to find the error minimizing weights due to the nonlinearity of the objective (and thus getting stuck in local minima), another challenge is to address the perpetual problem of overfitting. We would like the trained network to fit true patterns in the data and not those that are idiosyncratic, due to spurious patterns in training data because of uninformative features or noisy data. We discuss below the various methods to address overfitting.
One way in which over-fitting can occur is with continuing to train weights until the weights converge or the classification error on the training data is minimized. In fact, if we draw a graph with the number of epochs of training on the x axis, and the classification error on the y axis, we will often see the
standard overfitting phenomenon. The classification error in the training set will continue to decrease as the number of epochs increases. However, there will be some point after which the error rate on the validation set increases. This is the point at which overfitting happens. How can we find the optimal time at which to stop training? One standard approach is to use a validation set (or multi-fold cross-validation). The data is divided into two parts, a training set and a validation set. Weights are adjusted by running back propagation on the training set, At the end of each epoch (that is after n additional updates), the classification error of the newly updated network on the validation set is computed. As soon as the validation set error rate starts increasing, training is stopped, and the previous network weights are returned. To gain intuition for why a network can overfit to data from training for too long, notice that the sigmoid activation function is linear around inputs close to zero but non-linear for inputs further away from zero. By starting training with small weights (and with standardized input data so that the magnitude of the feature vectors in the input is also small), the network is initially searching through a space of approximately linear hypotheses. But as training continues it will seek hypotheses with increasingly nonlinear, and thus increasingly complex, decision boundaries.
In order to better understand why overfitting is an issue in neural networks, and to gain insight on other ways to prevent it, consider a network with a single complete hidden layer, in which the number of hidden units is equal to the number of training examples. This network can get an error arbitrarily close to zero on the training set, because each hidden unit can learn to recognize exactly one of the training examples! The network would learn a Disjunctive Normal Form (DNF) representation of the data; each hidden unit the conjunction of features in exactly one example and the output unit the disjunction of the activations of the hidden units. This is the extreme case of overfitting, where the network just memorizes the training data and likely has an extremely hard time generalizing to other examples. From this, we see that there’s a tradeoff in the number of hidden units used in a neural network. With too few hidden units, the hypothesis space might not be rich enough to represent the actual function being learned, which means that the network might underfit the data. On the other hand, more hidden units means more weights to learn, and makes it more likely that the network will overfit the data. This leads to the question: how many hidden units should we use? In addition, for a given number of hidden units, we could choose to remove some of the edges between the different layers— how many edges should we have in our network? Suppose I say, “I’m going to use a feed-forward neural network with a single hidden layer for my learning task”. I have specified all the details of the model, except for the number of hidden units. (Recall that a model itself specifies
You might say, “I’m going to use a feed-forward neural network with a single (not necessarily complete) hidden layer for my learning task.” Now the model space is larger— we also allow for the wiring pattern to vary, with some weights dropped, and there are lots of different possible network topologies for a given number of hidden units. Consequently, the model selection problem is more difficult. One algorithm, given the yucky name “optimal brain damage,” begins with a large, complete network. In each round, after training to minimize the error on the training data, it looks at each of the edges and determines the ones that are least “salient” to the network with respect to error on the training data, and removes them. Hence the name: “brain damage” means that some of the edges in the network are broken, while “optimal” means that there is an attempt to break the edges in a way that will cause least damage. There are many details that need to be addressed in implementing such an algorithm. For example, how many weights to remove, and when to stop. The key question is, how does one determine which weights to remove? There are several options:
Another remedy to over-fitting is suggested by the earlier insight that small weights in neural networks tend to correspond to simpler hypotheses, while overfitting usually involves large weights. This suggests that one might try to use a regularization penalty to protect against overly complex hypotheses. The error function to be minimized would is composed of two terms, one describing the training set error and one the complexity of the network as expressed in the magnitudes of the weights. A common regularization penalty is
Error (w) =
i∈D
∑^ m
k=
(yik − aik)^2 + λ(w · w), (9)
where yik is the value on the kth output on the ith example in the training data and aik is the corresponding activation level in the network. When combined with gradient descent this leads to a process of “weight decay,” with large weights decreased in size during training if they don’t lead to a significant increase in squared error. The regularization parameter λ > 0 is a parameter of the learning algorithm to be tuned, and this can be achieved by validation.
If there is a lot of symmetry in a domain, it might make sense to force some of the weights in the network to be the same. For example, consider an image processing problem. For concreteness, let’s say the input data consists of a 3x image of units, numbered as follows:
x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9
Suppose we want to build an array of hidden units that detect features of 2x2 regions. There will be four hidden units, corresponding to the top left, top right, bottom left and bottom right of the image. We want each of these hidden units to compute the same function of its inputs, so we need to force some of the weights in the network to be the same. E.g., the weights from x 1 to the first hidden unit, from x 2 to the second hidden unit, from x 4 to the third hidden unit and from x 5 to the fourth hidden unit should all be the same. This process of forcing weights on different edges to be the same is called weight sharing. In an implementation of back-propagation, weight-sharing can be implemented by, for example, (i) storing a pointer to the actual weight with each edge, rather than the weight itself. Edges that share weights will point to the same weight. (ii) updating all weights separately, but then after each update of weights, replacing all shared weights with the average across all weights.
Weight sharing was used very successfully be LeCun et al. (1989) within a digit recognition system. There are two good reasons to adopt weight sharing in some domains. One is that it exploits prior domain knowledge that we have about symmetry in the domain. The other is that it reduces the number of weights that have to be learned, which is useful because it takes more samples to learn more weights reliably.
5 Discussion: NNs and DTs
We’ve now seen two major paradigms for supervised learning: decision trees and neural networks. How do they compare to each other? The following table summarizes some of the main points of comparison. It is by no means an exhaustive list.
speech. To sharpen the effect, they used a high-pitched voice saying “I want to go to grandmother’s house.” It really sounded like a child learning to speak and was picked up in the popular press. This application really made neural net- works quite popular, particularly in cognitive science. It combined a physically plausible neural network model with a convincing demonstration of gradually improving behavior.
Image Recognition There have been many applications of neural networks in the area of image processing. One of them — digit recognition — is explored in the homework. A similar application is to face recognition (Mitchell 1997). The input is a database consisting of photos. Each photo is labeled with the name of the person, as well as other aspects such as which way the person is facing (pose) and whether the person is wearing sunglasses. A network was then trained on 260 images with 20 different people appearing in them. Each image was 128x pixels, with each pixel taking on a greyscale value between 0 and 255. A neural network was able to achieve 90% accuracy in determining the pose of a photo, and over 70% accuracy in determining the identity of a person. For pose (left, straight, right, up), the image was simplified to 30x32 pixels and a network with 3 hidden units and a distributed output encoding with 4 output units was adopted. Another earlier application of neural networks to image recognition was to automated driving. A system called ALVINN was developed that has been used to control a vehicle on a public highway for up to 90 miles and at up to 70 mph (Pomerleau’93). The input to the network was a 30x32 pixel image, and the output was one of 30 steering directions (with a distributed encoding.) A network with four hidden units was used. Training data was obtained by observing a human driver. So really, the function that ALVINN tried to learn was to predict what a human driver would do, given the visual data. ALVINN was able to travel at 70mph for 90 miles. A later system was able to drive “hands free across America.” One interesting effect is that humans were too good drivers to provide ALVINN with good training data. Because a human would never get into bad situations, there would be no training data to tell ALVINN what to do in a bad situation. As a result, if it got into a bad situation, ALVINN’s prediction was likely to lead to a crash. To get around this problem, the designers of ALVINN added skewed images of the road to the training data, to simulate the type of input that would be received in bad situations. (This provides the interpolation property mentioned earlier in the notes.) Another interesting point is that ALVINN didn’t need to be able to steer fantastically well. The system could correct errors very quickly, approximately every 10th of a second. As a classifier, the neural network was quick enough to make decisions very quickly. A system that did sophisticated image processing to decide which way to steer might have taken longer to make decisions, and therefore not be able to correct errors quickly enough.
Dimensionality reduction. Neural networks can be easily used to find con- cise encodings of data. For this, an auto-associative neural network is adopted in which the number of output units is equal to the number of input units and the target function is identity so that the neural network tries to learn a hy- pothesis that will fit the input. By insisting on a small number of hidden units and a layered architecture, the activation level on the hidden units provides a low-dimensional representation of the data. It is known that four layers (i.e., three hidden layers) are required to reliably achieve a non-linear dimensionality reduction (Kramer’91, DeMers and Cottrell’93).
EEG study Tarassenko (1998) reports the results of a case study to EEG (electroencephalography) for sleep studies. Overnight sleep recordings of EEG levels were made of 9 adults, with measurements at 128Hz and chunked into 1 second intervals and converted into a frequency domain (so that 1 second was represented by 10 coefficients). Experts annotated the intervals as wake- ful, rapid-eye movement (REM) or deep sleep and where three experts agreed this became the labeled data. There was 4,920, 43,590 and 42,630 seconds of wakefulness, REM and deep sleep data and to balance the data set 4,920 secs of each class were used. The data was also standardized to Normal(0,1). Ul- timately, the balanced data set was partitioned at random into 4,920 training, 4,920 validation and 4,920 test instances. A distributed “1 out of 3” encoding was used on the output. Linear regression with 10-fold testing generated average classification error on a test set of 20.0%. Following model selection using the validation set, a network with H = 7 hidden units was adopted, and provided 10.6% classification error on the test set.
Diabetes study. Tarassenko (1998) also reports the results of a case study to predict whether or not a female member of the Pima Indian tribe is diabetic or not based on physiological parameters. The Pima India tribe has the highest prevalence of type 2 diabetes in the World and has been the subject of great study. Parameters recorded for each of 750 women were: number of times pregnant, plasma glucose concentration at 2hrs in an oral glucose tolerance test, diastolic blood pressure, triceps skin fold thickness, 2-hour serum insulin, body mass index, diabetes pedigree function, age, diabetic or not. But all parameters were recorded for only 380 women. Dropping the insulin reading, the number of records with complete information was 532, of which 177 were diabetics. From this a balanced data set of 352 (176 diabetic, 176 non-diabetic) was adopted. This was used in cross-validation, with 11 subsets of 32 instances each, and 11 experiments in which a different test set of 32 instances was held out, with the remaining 320 instances split into a training and validation set. (So, a 5:5:1 structure to the partition.) Linear regression provided test classification error of 23.6% error when used with 11-fold cross- testing (i.e., 11 random partitions of (320:32) training and test data.) A network model with 6 hidden units was adopted through cross-validation (employing random restart) and the 7-6-1 architecture generated test classification error in
units on the previous input. In this way, the network learns to represent the appropriate summarization information about the sequence of previous inputs in the activation level of the hidden units that provide this recurrence. Such networks are popular for predicting time sequence data and have applications, for example, in finance. Specialized algorithms can be used to train recurrent networks, but they can also be trained by unrolling and applying weight-sharing ideas to make sure the weights are the same across each unrolled network.