Perceptron: Difference between revisions
Line 42: | Line 42: | ||
1. Initialise weights and threshold. |
1. Initialise weights and threshold. |
||
Set <math>wi(t)</math>, (1 <= i <= |
Set <math>wi(t)</math>, (1 <= i <= m), to be the weight i at time t, and ø to be the threshold value in the output node. |
||
Set w0 to be -ø,the bias, and x0 to be always 1. |
Set w0 to be -ø,the bias, and x0 to be always 1. |
||
Set <math>w_i(1)</math> to small random values, thus initialising the weights and threshold. |
Set <math>w_i(1)</math> to small random values, thus initialising the weights and threshold. |
||
Line 48: | Line 48: | ||
2. Present input and desired output |
2. Present input and desired output |
||
Present input <math>x_1, x_2, ..., |
Present input <math>x_1, x_2, ..., x_m</math>and desired output d(t) |
||
3. Calculate the actual output |
3. Calculate the actual output |
||
<math>y(t) = fh[w_1(t)x_1(t) + w_2(t)x_2(t) + .... + |
<math>y(t) = fh[w_1(t)x_1(t) + w_2(t)x_2(t) + .... + w_m(t)x_m(t)]</math> |
||
4. Adapts weights |
4. Adapts weights |
||
wi(t+1) = wi(t) + ñ[d(t) - y(t)]xi(t) , where 0 <= |
wi(t+1) = wi(t) + ñ[d(t) - y(t)]xi(t) , where 0 <= m <= 1 is a positive gain function that controls the adaption rate. |
||
Steps 3 and 4 are repeated until the iteration error is less than a user-specified error threshold or a predetermined number of iterations have been completed. |
Steps 3 and 4 are repeated until the iteration error is less than a user-specified error threshold or a predetermined number of iterations have been completed. |
Revision as of 17:59, 27 May 2010
The perceptron is a type of artificial neural network invented in 1957 at the Cornell Aeronautical Laboratory by Frank Rosenblatt. It can be seen as the simplest kind of feedforward neural network: a linear classifier.
Definition
The perceptron is a binary classifier which maps its input (a real-valued vector) to an output value (a single binary value) across the matrix.
where is a vector of real-valued weights and is the dot product (which computes a weighted sum). is the 'bias', a constant term that does not depend on any input value.
The value of (0 or 1) is used to classify as either a positive or a negative instance, in the case of a binary classification problem. If is negative, then the weighted combination of inputs must produce a positive value greater than in order to push the classifier neuron over the 0 threshold. Spatially, the bias alters the position (though not the orientation) of the decision boundary. The perceptron learning algorithm does not terminate if the learning set is not linearly separable.
The perceptron are considered the simplest kind of feed-forward neural network.
Learning algorithm
The learning algorithm is the same across all neurons, therefore everything that follows is applied to a single neuron in isolation. We first define some variables:
- denotes the j-th item in the n-dimensional input vector
- denotes the j-th item in the weight vector
- denotes the output from the neuron when presented with input
- is a constant where (learning rate)
Assume for the convenience that the bias term is zero. An extra dimension can be added to the input vectors x with , in which case replaces the bias term.
Let be training set of training examples, where is the input vector to the perceptron and is the desired output value of the perceptron for that input vector.
Learning Algorithm steps:
1. Initialise weights and threshold.
Set , (1 <= i <= m), to be the weight i at time t, and ø to be the threshold value in the output node. Set w0 to be -ø,the bias, and x0 to be always 1. Set to small random values, thus initialising the weights and threshold.
2. Present input and desired output
Present input and desired output d(t)
3. Calculate the actual output
4. Adapts weights
wi(t+1) = wi(t) + ñ[d(t) - y(t)]xi(t) , where 0 <= m <= 1 is a positive gain function that controls the adaption rate.
Steps 3 and 4 are repeated until the iteration error is less than a user-specified error threshold or a predetermined number of iterations have been completed.
Separability and Convergence
The training set is said to be linearly separable if there exists a positive constant and a weight vector such that for all . That is, if we say that is the weight vector to the perceptron, then the output of the perceptron, , multiplied by the desired output of the perceptron, , must be greater than the positive constant, , for all input-vector/output-value pairs in .
Novikoff (1962) proved that the perceptron algorithm converges after a finite number of iterations if the data set is linearly separable. The idea of the proof is that the weight vector is always adjusted by a bounded amount in a direction that it has a negative dot product with, and thus can be bounded above by where t is the number of changes to the weight vector, but it can also be bounded below by because if there exists an (unknown) satisfactory weight vector, then every change makes progress in this (unknown) direction by a positive amount that depends only on the input vector. This can be used to show that the number of mistakes (changes to the weight vector, i.e. ) is bounded by where is the maximum norm of an input vector. However, if the training set is not linearly separable, the above online algorithm will not converge.
Note that the decision boundary of a perceptron is invariant with respect to scaling of the weight vector, i.e. a perceptron trained with initial weight vector and learning rate is an identical estimator to a perceptron trained with initial weight vector and learning rate 1. Thus, since the initial weights become irrelevant with increasing number of iterations, the learning rate does not matter in the case of the perceptron and is usually just set to one.
Variants
The pocket algorithm with ratchet (Gallant, 1990) solves the stability problem of perceptron learning by keeping the best solution seen so far "in its pocket". The pocket algorithm then returns the solution in the pocket, rather than the last solution.
The -perceptron further utilised a preprocessing layer of fixed random weights, with thresholded output units. This enabled the perceptron to classify analogue patterns, by projecting them into a binary space. In fact, for a projection space of sufficiently high dimension, patterns can become linearly separable.
As an example, consider the case of having to classify data into two classes. Here is a small such data set, consisting of two points coming from two Gaussian distributions.
-
Two class gaussian data
-
A linear classifier operating on the original space
-
A linear classifier operating on a high-dimensional projection
A linear classifier can only separate things with a hyperplane, so it's not possible to classify all the examples perfectly. On the other hand, we may project the data into a large number of dimensions. In this case a random matrix was used to project the data linearly to a 1000-dimensional space; then each resulting data point was transformed through the hyperbolic tangent function. A linear classifier can then separate the data, as shown in the third figure. However the data may still not be completely separable in this space, in which the perceptron algorithm would not converge. In the example shown, stochastic steepest gradient descent was used to adapt the parameters.
Furthermore, by adding nonlinear layers between the input and output, one can separate all data and indeed, with enough training data, model any well-defined function to arbitrary precision. This model is a generalization known as a multilayer perceptron.
It should be kept in mind, however, that the best classifier is not necessarily that which classifies all the training data perfectly. Indeed, if we had the prior constraint that the data come from equi-variant Gaussian distributions, the linear separation in the input space is optimal.
Other training algorithms for linear classifiers are possible: see, e.g., support vector machine and logistic regression.
Example
A perceptron (X1, X2 input, X0*W0=b, TH=0.5) learns how to perform a NAND function:
Input | Initial | Output | Final | |||||||||||||||
Threshold | Learning Rate | Sensor values | Desired output | Weights | Calculated | Sum | Network | Error | Correction | Weights | ||||||||
TH | LR | X0 | X1 | X2 | Z | w0 | w1 | w2 | C0 | C1 | C2 | S | N | E | R | W0 | W1 | W2 |
X0 x w0 | X1 x w1 | X2 x w2 | C0+C1+C2 | IF(S>TH,1,0) | Z-N | LR x E | ||||||||||||
0.5 | 0.1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | +0.1 | 0.1 | 0 | 0 |
0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 | -0.2 | -0.1 |
0.5 | 0.1 | 1 | 0 | 1 | 1 | 0.8 | -0.2 | -0.1 | 0.8 | 0 | -0.1 | 0.7 | 1 | 0 | 0 | 0.8 | -0.2 | -0.1 |
Note: Initial weight equals final weight of previous iteration. A too high learning rate makes the perceptron periodically oscillate around the solution. A possible enhancement is to use starting with n=1 and incrementing it by 1 when a loop in learning is found.
Multiclass perceptron
Like most other techniques for training linear classifiers, the perceptron generalizes naturally to multiclass classification. Here, the input and the output are drawn from arbitrary sets. A feature representation function maps each possible input/output pair to a finite-dimensional real-valued feature vector. As before, the feature vector is multiplied by a weight vector , but now the resulting score is used to choose among many possible outputs:
Learning again iterates over the examples, predicting an output for each, leaving the weights unchanged when the predicted output matches the target, and changing them when it does not. The update becomes:
This multiclass formulation reduces to the original perceptron when is a real-valued vector, is chosen from , and .
For certain problems, input/output representations and features can be chosen so that can be found efficiently even though is chosen from a very large or even infinite set.
In recent years, perceptron training has become popular in the field of natural language processing for such tasks as part-of-speech tagging and syntactic parsing (Collins, 2002).
History
- See also: History of artificial intelligence, AI Winter and Frank Rosenblatt
Although the perceptron initially seemed promising, it was eventually proved that perceptrons could not be trained to recognise many classes of patterns. This led to the field of neural network research stagnating for many years, before it was recognised that a feedforward neural network with two or more layers (also called a multilayer perceptron) had far greater processing power than perceptrons with one layer (also called a single layer perceptron). Single layer perceptrons are only capable of learning linearly separable patterns; in 1969 a famous book entitled Perceptrons by Marvin Minsky and Seymour Papert showed that it was impossible for these classes of network to learn an XOR function. They conjectured (incorrectly) that a similar result would hold for a perceptron with three or more layers. Three years later Stephen Grossberg published a series of papers introducing networks capable of modelling differential, contrast-enhancing and XOR functions. (The papers were published in 1972 and 1973, see e.g.: Grossberg, Contour enhancement, short-term memory, and constancies in reverberating neural networks. Studies in Applied Mathematics, 52 (1973), 213-257, online [1]). Nevertheless the often-cited Minsky/Papert text caused a significant decline in interest and funding of neural network research. It took ten more years until neural network research experienced a resurgence in the 1980s. This text was reprinted in 1987 as "Perceptrons - Expanded Edition" where some errors in the original text are shown and corrected.
More recently, interest in the perceptron learning algorithm has increased again after Freund and Schapire (1998) presented a voted formulation of the original algorithm (attaining large margin) and suggested that one can apply the kernel trick to it.
References
- Rosenblatt, Frank (1958), The Perceptron: A Probabilistic Model for Information Storage and Organization in the Brain, Cornell Aeronautical Laboratory, Psychological Review, v65, No. 6, pp. 386-408. doi:10.1037/h0042519.
- Minsky M. L. and Papert S. A. 1969. Perceptrons. Cambridge, MA: MIT Press.
- Freund, Y. and Schapire, R. E. 1998. Large margin classification using the perceptron algorithm. In Proceedings of the 11th Annual Conference on Computational Learning Theory (COLT' 98). ACM Press.
- Freund, Y. and Schapire, R. E. 1999. Large margin classification using the perceptron algorithm. In Machine Learning 37(3):277-296, 1999.
- Gallant, S. I. (1990). Perceptron-based learning algorithms. IEEE Transactions on Neural Networks, vol. 1, no. 2, pp. 179-191.
- Novikoff, A. B. (1962). On convergence proofs on perceptrons. Symposium on the Mathematical Theory of Automata, 12, 615-622. Polytechnic Institute of Brooklyn.
- Widrow, B., Lehr, M.A., "30 years of Adaptive Neural Networks: Perceptron, Madaline, and Backpropagation," Proc. IEEE, vol 78, no 9, pp. 1415-1442, (1990).
- Collins, M. 2002. Discriminative training methods for hidden Markov models: Theory and experiments with the perceptron algorithm in Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP '02)
- Yin, Hongfeng (1996), Perceptron-Based Algorithms and Analysis, Spectrum Library, Concordia University, Canada
External links
This article's use of external links may not follow Wikipedia's policies or guidelines. (January 2010) |
- SergeiAlderman-ANN.rtf
- Chapter 3 Weighted networks - the perceptron and chapter 4 Perceptron learning of Neural Networks - A Systematic Introduction by Raúl Rojas (ISBN 978-3540605058)
- Pithy explanation of the update rule by Charles Elkan
- C# implementation of a perceptron
- History of perceptrons
- Mathematics of perceptrons
- Perceptron demo applet and an introduction by examples