CHAPTER 4 A visual proof that neural nets can compute any function

来源:互联网 发布:pc越狱软件 编辑:程序博客网 时间:2024/05/16 05:02
One of the most striking facts about neural networks is that they cancompute any function at all. That is, suppose someone hands you somecomplicated, wiggly function,f(x)

:

No matter what thefunction, there is guaranteed to be a neural network so that for everypossible input,x

, the value f(x)

(or some close approximation) isoutput from the network, e.g.:

This result holds even if the function has many inputs, f=f(x1,,xm)

, and many outputs. For instance, here's a networkcomputing a function with m=3 inputs and n=2

outputs:

This result tells us that neural networks have a kind ofuniversality. No matter what function we want to compute, weknow that there is a neural network which can do the job.

What's more, this universality theorem holds even if we restrict ournetworks to have just a single layer intermediate between the inputand the output neurons - a so-called single hidden layer. So evenvery simple network architectures can be extremely powerful.

The universality theorem is well known by people who use neuralnetworks. But why it's true is not so widely understood. Most of theexplanations available are quite technical. For instance, one of theoriginal papers proving theresult**Approximation by superpositions of a sigmoidal function, by George Cybenko (1989). The result was very much in the air at the time, and several groups proved closely related results. Cybenko's paper contains a useful discussion of much of that work. Another important early paper is Multilayer feedforward networks are universal approximators, by Kurt Hornik, Maxwell Stinchcombe, and Halbert White (1989). This paper uses the Stone-Weierstrass theorem to arrive at similar results. did sousing the Hahn-Banach theorem, the Riesz Representation theorem, andsome Fourier analysis. If you're a mathematician the argument is notdifficult to follow, but it's not so easy for most people. That's apity, since the underlying reasons for universality are simple andbeautiful.

In this chapter I give a simple and mostly visual explanation of theuniversality theorem. We'll go step by step through the underlyingideas. You'll understand why it's true that neural networks cancompute any function. You'll understand some of the limitations ofthe result. And you'll understand how the result relates to deepneural networks.

To follow the material in the chapter, you do not need to have readearlier chapters in this book. Instead, the chapter is structured tobe enjoyable as a self-contained essay. Provided you have just alittle basic familiarity with neural networks, you should be able tofollow the explanation. I will, however, provide occasional links toearlier material, to help fill in any gaps in your knowledge.

Universality theorems are a commonplace in computer science, so muchso that we sometimes forget how astonishing they are. But it's worthreminding ourselves: the ability to compute an arbitrary function istruly remarkable. Almost any process you can imagine can be thoughtof as function computation. Consider the problem of naming a piece ofmusic based on a short sample of the piece. That can be thought of ascomputing a function. Or consider the problem of translating aChinese text into English. Again, that can be thought of as computinga function**Actually, computing one of many functions, since there are often many acceptable translations of a given piece of text.. Or consider the problem of taking an mp4 movie file andgenerating a description of the plot of the movie, and a discussion ofthe quality of the acting. Again, that can be thought of as a kind offunction computation**Ditto the remark about translation and there being many possible functions.. Universality means that, inprinciple, neural networks can do all these things and many more.

Of course, just because we know a neural network exists that can (say)translate Chinese text into English, that doesn't mean we have goodtechniques for constructing or even recognizing such a network. Thislimitation applies also to traditional universality theorems formodels such as Boolean circuits. But, as we've seen earlier in thebook, neural networks have powerful algorithms for learning functions.That combination of learning algorithms + universality is anattractive mix. Up to now, the book has focused on the learningalgorithms. In this chapter, we focus on universality, and what itmeans.

Two caveats

Before explaining why the universality theorem is true, I want tomention two caveats to the informal statement "a neural network cancompute any function".

First, this doesn't mean that a network can be used to exactlycompute any function. Rather, we can get anapproximationthat is as good as we want. By increasing the number of hiddenneurons we can improve the approximation. For instance,earlier I illustrated a networkcomputing some function f(x)

using three hidden neurons. For mostfunctions only a low-quality approximation will be possible usingthree hidden neurons. By increasing the number of hidden neurons(say, to five) we can typically get a better approximation:

And we can do still better by further increasing the number of hiddenneurons.

To make this statement more precise, suppose we're given a functionf(x)

which we'd like to compute to within some desired accuracyϵ>0. The guarantee is that by using enough hidden neuronswe can always find a neural network whose outputg(x) satisfies|g(x)f(x)|<ϵ, for all inputs x

. In other words, theapproximation will be good to within the desired accuracy for everypossible input.

The second caveat is that the class of functions which can beapproximated in the way described are thecontinuous functions.If a function is discontinuous, i.e., makes sudden, sharp jumps, thenit won't in general be possible to approximate using a neural net.This is not surprising, since our neural networks compute continuousfunctions of their input. However, even if the function we'd reallylike to compute is discontinuous, it's often the case that acontinuous approximation is good enough. If that's so, then we canuse a neural network. In practice, this is not usually an importantlimitation.

Summing up, a more precise statement of the universality theorem isthat neural networks with a single hidden layer can be used toapproximate any continuous function to any desired precision. In thischapter we'll actually prove a slightly weaker version of this result,using two hidden layers instead of one. In the problems I'll brieflyoutline how the explanation can, with a few tweaks, be adapted to givea proof which uses only a single hidden layer.

Universality with one input and one output

To understand why the universality theorem is true, let's start byunderstanding how to construct a neural network which approximates afunction with just one input and one output:

It turns out that this is the core of the problem of universality.Once we've understood this special case it's actually pretty easy toextend to functions with many inputs and many outputs.

To build insight into how to construct a network to compute f

, let'sstart with a network containing just a single hidden layer, with twohidden neurons, and an output layer containing a single output neuron:

To get a feel for how components in the network work, let's focus onthe top hidden neuron. In the diagram below, click on the weight,w

, and drag the mouse a little ways to the right to increase w

.You can immediately see how the function computed by the top hiddenneuron changes:

As we learnt earlier in the book,what's being computed by the hidden neuron is σ(wx+b)

, whereσ(z)1/(1+ez)

is the sigmoid function. Up to now,we've made frequent use of this algebraic form. But for the proof ofuniversality we will obtain more insight by ignoring the algebraentirely, and instead manipulating and observing the shape shown inthe graph. This won't just give us a better feel for what's going on,it will also give us a proof**Strictly speaking, the visual approach I'm taking isn't what's traditionally thought of as a proof. But I believe the visual approach gives more insight into why the result is true than a traditional proof. And, of course, that kind of insight is the real purpose behind a proof. Occasionally, there will be small gaps in the reasoning I present: places where I make a visual argument that is plausible, but not quite rigorous. If this bothers you, then consider it a challenge to fill in the missing steps. But don't lose sight of the real purpose: to understand why the universality theorem is true. ofuniversality that applies to activation functions other than thesigmoid function.

To get started on this proof, try clicking on the bias, b

, in thediagram above, and dragging to the right to increase it. You'll seethat as the bias increases the graph moves to the left, but its shapedoesn't change.

Next, click and drag to the left in order to decrease the bias.You'll see that as the bias decreases the graph moves to the right,but, again, its shape doesn't change.

Next, decrease the weight to around 2

or 3

. You'll see that asyou decrease the weight, the curve broadens out. You might need tochange the bias as well, in order to keep the curve in-frame.

Finally, increase the weight up past w=100

. As you do, the curvegets steeper, until eventually it begins to look like a step function.Try to adjust the bias so the step occurs nearx=0.3

. Thefollowing short clip shows what your result should look like. Clickon the play button to play (or replay) the video:

We can simplify our analysis quite a bit by increasing the weight somuch that the output really is a step function, to a very goodapproximation. Below I've plotted the output from the top hiddenneuron when the weight isw=999

. Note that this plot is static,and you can't change parameters such as the weight.

It's actually quite a bit easier to work with step functions thangeneral sigmoid functions. The reason is that in the output layer weadd up contributions from all the hidden neurons. It's easy toanalyze the sum of a bunch of step functions, but rather moredifficult to reason about what happens when you add up a bunch ofsigmoid shaped curves. And so it makes things much easier to assumethat our hidden neurons are outputting step functions. Moreconcretely, we do this by fixing the weightw

to be some very largevalue, and then setting the position of the step by modifying thebias. Of course, treating the output as a step function is anapproximation, but it's a very good approximation, and for now we'lltreat it as exact. I'll come back later to discuss the impact ofdeviations from this approximation.

At what value of x

does the step occur? Put another way, how doesthe position of the step depend upon the weight and bias?

To answer this question, try modifying the weight and bias in thediagram above (you may need to scroll back a bit). Can you figure outhow the position of the step depends onw

and b? With a littlework you should be able to convince yourself that the position of thestep isproportional to b, and inversely proportionalto w

.

In fact, the step is at position s=b/w

, as you can see bymodifying the weight and bias in the following diagram:

It will greatly simplify our lives to describe hidden neurons usingjust a single parameter,s, which is the step position, s=b/w.Try modifying s

in the following diagram, in order to get used tothe new parameterization:

As noted above, we've implicitly set the weight w on the input to besome large value - big enough that the step function is a very goodapproximation. We can easily convert a neuron parameterized in thisway back into the conventional model, by choosing the biasb=ws

.

Up to now we've been focusing on the output from just the top hiddenneuron. Let's take a look at the behavior of the entire network. Inparticular, we'll suppose the hidden neurons are computing stepfunctions parameterized by step pointss1

(top neuron) and s2(bottom neuron). And they'll have respective output weights w1 andw2

. Here's the network:

What's being plotted on the right is the weighted output w1a1+w2a2 from the hidden layer. Here, a1 and a2 are theoutputs from the top and bottom hidden neurons,respectively**Note, by the way, that the output from the whole network isσ(w1a1+w2a2+b), where b is the bias on the output neuron. Obviously, this isn't the same as the weighted output from the hidden layer, which is what we're plotting here. We're going to focus on the weighted output from the hidden layer right now, and only later will we think about how that relates to the output from the whole network.. These outputs are denoted witha

s because they're often known as the neurons' activations.

Try increasing and decreasing the step point s1

of the top hiddenneuron. Get a feel for how this changes the weighted output from thehidden layer.It's particularly worth understanding what happens whens1 goespast s2

. You'll see that the graph changes shape when thishappens, since we have moved from a situation where the top hiddenneuron is the first to be activated to a situation where the bottomhidden neuron is the first to be activated.

Similarly, try manipulating the step point s2

of the bottom hiddenneuron, and get a feel for how this changes the combined output fromthe hidden neurons.

Try increasing and decreasing each of the output weights. Notice howthis rescales the contribution from the respective hidden neurons.What happens when one of the weights is zero?

Finally, try setting w1

to be 0.8 and w2 to be 0.8. Youget a "bump" function, which starts at point s1, ends at points2, and has height 0.8

. For instance, the weighted output mightlook like this:

Of course, we can rescale the bump to have any height at all. Let'suse a single parameter,h

, to denote the height. To reduce clutterI'll also remove the "s1=" and "w1=

" notations.

Try changing the value of h

up and down, to see how the height ofthe bump changes. Try changing the height so it's negative, andobserve what happens. And try changing the step points to see howthat changes the shape of the bump.

You'll notice, by the way, that we're using our neurons in a way thatcan be thought of not just in graphical terms, but in moreconventional programming terms, as a kind ofif-then-elsestatement, e.g.:

    if input >= step point:        add 1 to the weighted output    else:        add 0 to the weighted output

For the most part I'm going to stick with the graphical point of view.But in what follows you may sometimes find it helpful to switch pointsof view, and think about things in terms ofif-then-else.

We can use our bump-making trick to get two bumps, by gluing two pairsof hidden neurons together into the same network:

I've suppressed the weights here, simply writing the h values foreach pair of hidden neurons. Try increasing and decreasing both h

values, and observe how it changes the graph. Move the bumps aroundby changing the step points.

More generally, we can use this idea to get as many peaks as we want,of any height. In particular, we can divide the interval[0,1]

upinto a large number, N, of subintervals, and use N pairs of hiddenneurons to set up peaks of any desired height. Let's see how thisworks forN=5

. That's quite a few neurons, so I'm going to packthings in a bit. Apologies for the complexity of the diagram: I couldhide the complexity by abstracting away further, but I think it'sworth putting up with a little complexity, for the sake of getting amore concrete feel for how these networks work.

You can see that there are five pairs of hidden neurons. The steppoints for the respective pairs of neurons are0,1/5, then 1/5,2/5, and so on, out to 4/5,5/5

. These values are fixed - theymake it so we get five evenly spaced bumps on the graph.

Each pair of neurons has a value of h

associated to it. Remember,the connections output from the neurons have weights h and h (notmarked). Click on one of the h

values, and drag the mouse to theright or left to change the value. As you do so, watch the functionchange. By changing the output weights we're actuallydesigning the function!

Contrariwise, try clicking on the graph, and dragging up or down tochange the height of any of the bump functions. As you change theheights, you can see the corresponding change inh

values. And,although it's not shown, there is also a change in the correspondingoutput weights, which are+h and h

.

In other words, we can directly manipulate the function appearing inthe graph on the right, and see that reflected in theh

values onthe left. A fun thing to do is to hold the mouse button down and dragthe mouse from one side of the graph to the other. As you do this youdraw out a function, and get to watch the parameters in the neuralnetwork adapt.

Time for a challenge.

Let's think back to the function I plotted at the beginning of thechapter:

I didn't say it at the time, but what I plotted is actually thefunction

f(x)=0.2+0.4x2+0.3xsin(15x)+0.05cos(50x),(113)
plotted over x from 0 to 1, and with the y axis takingvalues from 0 to 1

.

That's obviously not a trivial function.

You're going to figure out how to compute it using a neural network.

In our networks above we've been analyzing the weighted combinationjwjaj

output from the hidden neurons. We now know how toget a lot of control over this quantity. But, as I noted earlier,this quantity is not what's output from the network. What's outputfrom the network isσ(jwjaj+b) where b

is the biason the output neuron. Is there some way we can achieve control overthe actual output from the network?

The solution is to design a neural network whose hidden layer has aweighted output given byσ1f(x)

, where σ1is just the inverse of the σ

function. That is, we want theweighted output from the hidden layer to be:

If we can do this, then the output from the network as a whole will bea good approximation tof(x)

**Note that I have set the bias on the output neuron to 0

..

Your challenge, then, is to design a neural network to approximate thegoal function shown just above. To learn as much as possible, I wantyou to solve the problem twice. The first time, please click on thegraph, directly adjusting the heights of the different bump functions.You should find it fairly easy to get a good match to the goalfunction. How well you're doing is measured by theaverage deviation between the goal function and the function the network isactually computing. Your challenge is to drive the average deviationaslow as possible. You complete the challenge when you drivethe average deviation to0.40

or below.

Once you've done that, click on "Reset" to randomly re-initializethe bumps. The second time you solve the problem, resist the urge toclick on the graph. Instead, modify theh

values on the left-handside, and again attempt to drive the average deviation to 0.40

orbelow.

You've now figured out all the elements necessary for the network toapproximately compute the functionf(x)

! It's only a coarseapproximation, but we could easily do much better, merely byincreasing the number of pairs of hidden neurons, allowing more bumps.

In particular, it's easy to convert all the data we have found backinto the standard parameterization used for neural networks. Let mejust recap quickly how that works.

The first layer of weights all have some large, constant value, say w=1000

.

The biases on the hidden neurons are just b=ws

. So, forinstance, for the second hidden neuron s=0.2 becomes b=1000×0.2=200

.

The final layer of weights are determined by the h

values. So, forinstance, the value you've chosen above for the first h,h=

1.3, means thatthe output weights from the top two hidden neurons are1.3 and -1.3, respectively. Andso on, for the entire layer of output weights.

Finally, the bias on the output neuron is 0

.

That's everything: we now have a complete description of a neuralnetwork which does a pretty good job computing our original goalfunction. And we understand how to improve the quality of theapproximation by improving the number of hidden neurons.

What's more, there was nothing special about our original goalfunction, f(x)=0.2+0.4x2+0.3sin(15x)+0.05cos(50x)

. Wecould have used this procedure for any continuous function from [0,1] to [0,1]

. In essence, we're using our single-layer neuralnetworks to build a lookup table for the function. And we'll be ableto build on this idea to provide a general proof of universality.

Many input variables

Let's extend our results to the case of many input variables. Thissounds complicated, but all the ideas we need can be understood in thecase of just two inputs. So let's address the two-input case.

We'll start by considering what happens when we have two inputs to aneuron:

Here, we have inputs x

and y, with corresponding weights w1 andw2, and a bias b on the neuron. Let's set the weight w2 to0, and then play around with the first weight, w1, and the bias,b

, to see how they affect the output from the neuron:

x=1y=1Output

As you can see, with w2=0

the input y makes no difference tothe output from the neuron. It's as though x

is the only input.

Given this, what do you think happens when we increase the weightw1

to w1=100, with w2 remaining 0

? If you don'timmediately see the answer, ponder the question for a bit, and see ifyou can figure out what happens. Then try it out and see if you'reright. I've shown what happens in the following movie:

Just as in our earlier discussion, as the input weight gets larger theoutput approaches a step function. The difference is that now thestep function is in three dimensions. Also as before, we can move thelocation of the step point around by modifying the bias. The actuallocation of the step point is sxb/w1

.

Let's redo the above using the position of the step as the parameter:

x=1y=1Output

Here, we assume the weight on the x

input has some large value- I've used w1=1000 - and the weight w2=0. Thenumber on the neuron is the step point, and the little x above thenumber reminds us that the step is in the x direction.Of course, it's also possible to get a step function in the ydirection, by making the weight on the y input very large (say, w2=1000), and the weight on the x equal to 0, i.e., w1=0

:

x=1y=1Output

The number on the neuron is again the step point, and in this case thelittle y

above the number reminds us that the step is in the ydirection. I could have explicitly marked the weights on the x andy inputs, but decided not to, since it would make the diagram rathercluttered. But do keep in mind that the littley marker implicitlytells us that the y weight is large, and the x weight is 0

.

We can use the step functions we've just constructed to compute athree-dimensional bump function. To do this, we use two neurons, eachcomputing a step function in thex

direction. Then we combine thosestep functions with weight h and h, respectively, where h

isthe desired height of the bump. It's all illustrated in the followingdiagram:

x=1y=1Weighted output from hidden layer

Try changing the value of the height, h

. Observe how it relates tothe weights in the network. And see how it changes the height of thebump function on the right.

Also, try changing the step point 0.30

associated to the top hiddenneuron. Witness how it changes the shape of the bump. What happenswhen you move it past the step point0.70

associated to the bottomhidden neuron?

We've figured out how to make a bump function in the x

direction.Of course, we can easily make a bump function in the y direction, byusing two step functions in the y direction. Recall that we do thisby making the weight large on the y input, and the weight 0 on thex

input. Here's the result:

x=1y=1Weighted output from hidden layer

This looks nearly identical to the earlier network! The only thingexplicitly shown as changing is that there's now littley

markers onour hidden neurons. That reminds us that they're producing y stepfunctions, not x step functions, and so the weight is very large onthe y input, and zero on the x

input, not vice versa. As before,I decided not to show this explicitly, in order to avoid clutter.

Let's consider what happens when we add up two bump functions, one inthe x

direction, the other in the y direction, both of height h

:

x=1y=1Weighted output from hidden layer

To simplify the diagram I've dropped the connections with zero weight.For now, I've left in the littlex

and y

markers on the hiddenneurons, to remind you in what directions the bump functions are beingcomputed. We'll drop even those markers later, since they're impliedby the input variable.

Try varying the parameter h

. As you can see, this causes the outputweights to change, and also the heights of both thex and y

bumpfunctions.

What we've built looks a little like a tower function:

x=1y=1Tower function

If we could build such tower functions, then we could use them toapproximate arbitrary functions, just by adding up many towers ofdifferent heights, and in different locations:

x=1y=1Many towers

Of course, we haven't yet figured out how to build a tower function.What we have constructed looks like a central tower, of height2h

,with a surrounding plateau, of height h

.

But we can make a tower function. Remember that earlier we sawneurons can be used to implement a type ofif-then-elsestatement:

    if input >= threshold:         output 1    else:        output 0

That was for a neuron with just a single input. What we want is toapply a similar idea to the combined output from the hidden neurons:

    if combined output from hidden neurons >= threshold:        output 1    else:        output 0

If we choose the threshold appropriately - say, a value of3h/2

, which is sandwiched between the height of the plateau and theheight of the central tower - we could squash the plateau down tozero, and leave just the tower standing.

Can you see how to do this? Try experimenting with the followingnetwork to figure it out. Note that we're now plotting the outputfrom the entire network, not just the weighted output from the hiddenlayer. This means we add a bias term to the weighted output from thehidden layer, and apply the sigma function. Can you find values forh

and b which produce a tower? This is a bit tricky, so if youthink about this for a while and remain stuck, here's two hints: (1)To get the output neuron to show the right kind ofif-then-elsebehaviour, we need the input weights (all h or h) to be large;and (2) the value of b

determines the scale of theif-then-else threshold.

x=1y=1Output

With our initial parameters, the output looks like a flattened versionof the earlier diagram, with its tower and plateau. To get thedesired behaviour, we increase the parameterh

until it becomeslarge. That gives the if-then-else thresholdingbehaviour. Second, to get the threshold right, we'll chooseb3h/2

. Try it, and see how it works!

Here's what it looks like, when we use h=10

:

Even for this relatively modest value of h

, we get a pretty goodtower function. And, of course, we can make it as good as we want byincreasingh still further, and keeping the bias as b=3h/2

.

Let's try gluing two such networks together, in order to compute twodifferent tower functions. To make the respective roles of the twosub-networks clear I've put them in separate boxes, below: each boxcomputes a tower function, using the technique described above. Thegraph on the right shows the weighted output from the secondhidden layer, that is, it's a weighted combination of tower functions.

x=1y=1Weighted output

In particular, you can see that by modifying the weights in the finallayer you can change the height of the output towers.

The same idea can be used to compute as many towers as we like. Wecan also make them as thin as we like, and whatever height we like.As a result, we can ensure that the weighted output from the secondhidden layer approximates any desired function of two variables:

x=1y=1Many towers

In particular, by making the weighted output from the second hiddenlayer a good approximation toσ1f

, we ensure theoutput from our network will be a good approximation to any desiredfunction,f

.

What about functions of more than two variables?

Let's try three variables x1,x2,x3

. The following network canbe used to compute a tower function in four dimensions:

Here, the x1,x2,x3 denote inputs to the network. The s1,t1 and so on are step points for neurons - that is, all theweights in the first layer are large, and the biases are set to givethe step pointss1,t1,s2,. The weights in the secondlayer alternate +h,h, where h is some very large number. Andthe output bias is 5h/2

.

This network computes a function which is 1

provided threeconditions are met: x1 is between s1 and t1;x2 is betweens2 and t2; and x3 is between s3 and t3. The network is0 everywhere else. That is, it's a kind of tower which is 1 in alittle region of input space, and 0

everywhere else.

By gluing together many such networks we can get as many towers as wewant, and so approximate an arbitrary function of three variables.Exactly the same idea works inm

dimensions. The only change neededis to make the output bias (m+1/2)h

, in order to get the right kindof sandwiching behavior to level the plateau.

Okay, so we now know how to use neural networks to approximate areal-valued function of many variables. What about vector-valuedfunctionsf(x1,,xm)Rn

? Of course, such a functioncan be regarded as just n separate real-valued functions, f1(x1,,xm),f2(x1,,xm), and so on. So we create anetwork approximating f1, another network for f2

, and so on.And then we simply glue all the networks together. So that's alsoeasy to cope with.

Problem

  • We've seen how to use networks with two hidden layers to approximate an arbitrary function. Can you find a proof showing that it's possible with just a single hidden layer? As a hint, try working in the case of just two input variables, and showing that: (a) it's possible to get step functions not just in the x
or y
  • directions, but in an arbitrary direction; (b) by adding up many of the constructions from part (a) it's possible to approximate a tower function which is circular in shape, rather than rectangular; (c) using these circular towers, it's possible to approximate an arbitrary function. To do part (c) it may help to use ideas from a bit later in this chapter.

Extension beyond sigmoid neurons

We've proved that networks made up of sigmoid neurons can compute anyfunction. Recall that in a sigmoid neuron the inputsx1,x2,

result in the output σ(jwjxj+b), where wjare the weights, b is the bias, and σ

is the sigmoidfunction:

What if we consider a different type of neuron, one using some otheractivation function,s(z)

:

That is, we'll assume that if our neurons has inputs x1,x2,

, weights w1,w2, and bias b, then the output iss(jwjxj+b)

.

We can use this activation function to get a step function, just as wedid with the sigmoid. Try ramping up the weight in the following, saytow=100

:

Just as with the sigmoid, this causes the activation function tocontract, and ultimately it becomes a very good approximation to astep function. Try changing the bias, and you'll see that we can setthe position of the step to be wherever we choose. And so we can useall the same tricks as before to compute any desired function.

What properties does s(z)

need to satisfy in order for this to work?We do need to assume that s(z) is well-defined as z and z. These two limits are the twovalues taken on by our step function. We also need to assume thatthese limits are different from one another. If they weren't, there'dbe no step, simply a flat graph! But provided the activation functions(z)

satisfies these properties, neurons based on such an activationfunction are universal for computation.

Problems

  • Earlier in the book we met another type of neuron known as a rectified linear unit. Explain why such neurons don't satisfy the conditions just given for universality. Find a proof of universality showing that rectified linear units are universal for computation.
  • Suppose we consider linear neurons, i.e., neurons with the activation functions(z)=z
  • . Explain why linear neurons don't satisfy the conditions just given for universality. Show that such neurons can't be used to do universal computation.

Fixing up the step functions

Up to now, we've been assuming that our neurons can produce stepfunctions exactly. That's a pretty good approximation, but it is onlyan approximation. In fact, there will be a narrow window of failure,illustrated in the following graph, in which the function behaves verydifferently from a step function:

In these windows of failure the explanation I've given foruniversality will fail.

Now, it's not a terrible failure. By making the weights input to theneurons big enough we can make these windows of failure as small as welike. Certainly, we can make the window much narrower than I've shownabove - narrower, indeed, than our eye could see. So perhaps wemight not worry too much about this problem.

Nonetheless, it'd be nice to have some way of addressing the problem.

In fact, the problem turns out to be easy to fix. Let's look at thefix for neural networks computing functions with just one input andone output. The same ideas work also to address the problem whenthere are more inputs and outputs.

In particular, suppose we want our network to compute some function,f

. As before, we do this by trying to design our network so thatthe weighted output from our hidden layer of neurons isσ1f(x)

:

If we were to do this using the technique described earlier, we'd usethe hidden neurons to produce a sequence of bump functions:

Again, I've exaggerated the size of the windows of failure, in orderto make them easier to see. It should be pretty clear that if we addall these bump functions up we'll end up with a reasonableapproximation toσ1f(x)

, except within the windowsof failure.

Suppose that instead of using the approximation just described, we usea set of hidden neurons to compute an approximation tohalf ouroriginal goal function, i.e., to σ1f(x)/2

. Ofcourse, this looks just like a scaled down version of the last graph:

And suppose we use another set of hidden neurons to compute anapproximation toσ1f(x)/2

, but with the bases ofthe bumps shifted by half the width of a bump:

Now we have two different approximations to σ1f(x)/2

. If we add up the two approximations we'll get an overallapproximation to σ1f(x). That overall approximationwill still have failures in small windows. But the problem will bemuch less than before. The reason is that points in a failure windowfor one approximation won't be in a failure window for the other. Andso the approximation will be a factor roughly 2

better in thosewindows.

We could do even better by adding up a large number, M

, ofoverlapping approximations to the function σ1f(x)/M. Provided the windows of failure are narrow enough, a point willonly ever be in one window of failure. And provided we're using alarge enough numberM

of overlapping approximations, the result willbe an excellent overall approximation.

Conclusion

The explanation for universality we've discussed is certainly not apractical prescription for how to compute using neural networks! Inthis, it's much like proofs of universality forNAND gates andthe like. For this reason, I've focused mostly on trying to make theconstruction clear and easy to follow, and not on optimizing thedetails of the construction. However, you may find it a fun andinstructive exercise to see if you can improve the construction.

Although the result isn't directly useful in constructing networks,it's important because it takes off the table the question of whetherany particular function is computable using a neural network. Theanswer to that question is always "yes". So the right question toask is not whether any particular function is computable, but ratherwhat's agood way to compute the function.

The universality construction we've developed uses just two hiddenlayers to compute an arbitrary function. Furthermore, as we'vediscussed, it's possible to get the same result with just a singlehidden layer. Given this, you might wonder why we would ever beinterested in deep networks, i.e., networks with many hidden layers.Can't we simply replace those networks with shallow, single hiddenlayer networks?

Chapter acknowledgments: Thanks to Jen Dodd and Chris Olah for many discussions about universality in neural networks. My thanks, in particular, to Chris for suggesting the use of a lookup table to prove universality. The interactive visual form of the chapter is inspired by the work of people such as Mike Bostock, Amit Patel, Bret Victor, andSteven Wittens.

While in principle that's possible, there are good practical reasonsto use deep networks. As argued inChapter 1, deep networkshave a hierarchical structure which makes them particularly welladapted to learn the hierarchies of knowledge that seem to be usefulin solving real-world problems. Put more concretely, when attackingproblems such as image recognition, it helps to use a system thatunderstands not just individual pixels, but also increasingly morecomplex concepts: from edges to simple geometric shapes, all the wayup through complex, multi-object scenes. In later chapters, we'll seeevidence suggesting that deep networks do a better job than shallownetworks at learning such hierarchies of knowledge. To sum up:universality tells us that neural networks can compute any function;and empirical evidence suggests that deep networks are the networksbest adapted to learn the functions useful in solving many real-worldproblems.

0 0
原创粉丝点击