perceptron: Display perceptron results for two-dimensional targets.

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/perceptron.R

Description

Display perceptron results in two-dimensional space via two-dimensional targets. Decision boundaries, valid regions, and training data are included.

Usage

1
perceptron(p, t, verbose = FALSE, W_0 = NULL, b_0 = NULL)

Arguments

p

A list of input vectors of uniform size.

t

A list of target vectors of uniform size.

verbose

A logical indicating if the function should report progress after each iteration. Default is FALSE.

W_0

A numeric matrix with initial values. Default is NULL, in which case the zero matrix initializes the algorithm.

b_0

A numeric matrix with initial values. Default is NULL, in which case the zero vector initializes the algorithm.

Details

Functon perceptron tries to identify a set of linear decision boundaries that correctly classify a set of inputs. In the case no such set of linear decision boundaries exists, nothing will happen without intervention from the user; i.e., the function will continue to iterate indefintely.

The function works to identify an optimum weight matrix \mathbf{W} and bias vector \mathbf{b} such that the i^{th} neuron correctly classifies that dimension of an input vector with regards to its supervised target. The i^{th} row of \mathbf{W} and \mathbf{b} corresponds to \mathbf{w}_i^T and bias vector b_i, respectively, meaning that n_i = \mathbf{w}_i^T\mathbf{p} + b_i ≥q 0 are classified as +1, while \mathbf{w}_i^T\mathbf{p} + b_i < 0 classify as 0. Thus, the perceptron function uses a hardlim activation function f(n_i) = a_i, where a_i equals 0 or 1.

Identification of a valid \mathbf{W} and \mathbf{b} proceeds algorithmically via stochastic descent, meaning that input vectors p evaluate one at a time, in order. If necessary, vectors evaluate multiple times, in order, until all points correctly match their targets.

Use of the verbse = TRUE option may be useful to help identify progress in slow-to-converge or seemingly unsolvable (read: possibly not linearly separable) problems. Note that weight matrices report as a long vector, so care must be taken to ensure appropriate interpretation.

Author(s)

Jason Mitchell

References

Martin T. Hagan, Howard B. Demuth, Mark H. Beale and Orlando De Jesús. 2014. Neural Network Design (2nd. ed.). Martin Hagan, Stillwater, OK, USA.

See Also

perceptron_plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
p <- list(matrix(c(2, 2), ncol=1), matrix(c(1, -2), ncol=1), 
matrix(c(-2, 2), ncol=1), matrix(c(-1, 1), ncol=1))
t <- list(0, 1, 0, 1)
verbose <- TRUE
perceptron(p, t, verbose)

p <- list(matrix(c(0, 2), ncol=1), matrix(c(1, 0), ncol=1), 
matrix(c(0, -2), ncol=1), matrix(c(2, 0), ncol=1))
t <- list(1, 1, 0, 0)
verbose <- TRUE
perceptron(p, t, verbose)

p <- list(c(1, 1), c(1, 2), c(2, -1), c(2, 0), c(-1, 2), c(-2, 1), c(-1, -1), c(-2 ,-2))
t <- list(c(0, 0), c(0, 0), c(0, 1), c(0, 1), c(1, 0), c(1, 0), c(1, 1), c(1, 1))
verbose <- TRUE
W_0 <- matrix(c(1, 0, 0, 1), ncol = 2)
b_0 <- c(1, 1)
ans <- perceptron(p, t, verbose, W_0, b_0)
## End(Not run)

jasmyace/rNeuralNetworkDesign documentation built on Jan. 2, 2022, 4:04 p.m.