Lecture #24 Mon 18 Mar 2002 NEC Next time, quiz passed out, and sign up sheet for final project stuff . . . Who can't make Friday 11-12 who can't make friday 1-2? Baker Shake reminder. 0. Scheme inner definitions 1. Examples of Neural Net applications 0. local So, just a quick thing to know about scheme, if you want to define variables that are only accessible within the scope of your function, you can use a thing called local. Examples: (define (f x) (local ((define a 1) (define b 2) (define c x)) (+ a b c x))) then (f 3) evaluates to 9. In general, this is the syntax: (local ((define var1 def1) (define var2 def2) . . . (define varN defN)) expression) where the expression is any scheme expression. Keep in mind, it can include references to var1 thru varN. NOTE: for the purposes of problem 5 on Homework 5, you can write scheme functions that include functions as local variables like this: (define (f x) (local ((define (g y) (+ y x))) (g x))) This function essentially just multiplies a number by 2. 1. Neural Net Examples So, now we want to talk about how these neural net things are actually used. a. Face Recognition We can break down a face into PIXELS, or atomic graphical elements, that can be binary input into a neural net. Say we have only black and white pixels. Each white pixel is a 0 and each black pixel is a 1. We serialize this input such that the 10 x 10 square image has pixels 1 to 100, and pixel 1 is the first input, pixel 2 is the next input, . . . , pixel 100 is the last input. These are inputs to our first layer of perceptrons. The output at the final layer of perceptrons is binary representation of a particular person. For example, 00100 codes for Mary, and 11010 codes for Bob, and 10101 codes for Jimmy. Now you just train the Neural Net, which will adjust the weights of the various perceptrons until you end up with weightings that will produce accurate output. Keep in mind, you'll need data to train on . . . pixelated pictures of Mary, Jimmy, Bob and whoever, so you can know whether a given output is correct or not for a given training session. We then train and train, and re-train until the neural net is good to go. b. OCR -- Post Office, Researchers in Montreal or was it Toronto? You know those zip codes that you write on all your snail mail? They're crucial to the US Postal Service. Neural nets have been trained to take the digits of the zip code as input, one digit at a time, and say what digit it is. Again, the digits are pixelated, a 10 X 10 square would contain 100 pixels, as we stated earlier . . . and this is the input, just as before. The output is a binary digit that codes for a number. We need four digits to code for all base 10 digits, and then we even have some left over! 0000 = 0 , 0101 = 5 , 1001 = 9. So after training our neural net, we hopefully end up with something that can turn a graphical digit into an abstract representation of a digit. Cool! c. English speech --> Nettalk, pronunciation of English text . . . So, what about producing English speech? We could send binary representations of characters as input to the neural net, but they'd have to be in context, so we'd send 50 or so characters at a time, and expect it to pronounce the middle character. Hello, how are you doing. This is English text. _ Assuming the above line is input to the neural net, it would hopefully produce the sound for "d". Again, everything has to be coded in binary. d. tanks in desert storm Sometimes you have to be careful what you train on . . . The problem with neural nets is that you never know what features they're actually training on. For example: The US military tried to use neural nets in Desert Storm for tank recognition, so unmanned tanks could identify enemy tanks and destroy them. They trained the neural net on multiple images of "friendly" and enemy tanks, and eventually had a decent program that seemed to correctly identify friendly and enemy tanks. Then, when they actually used the program in a real-world test phase with actual tanks, they found that the tanks would either shoot at nothing or shoot at everything. They certainly seemed to be incapable of distinguishing friendly or enemy tanks. Why was this? It turns out that the images they were training on always had glamour- shot type photos of friendly tanks, with an immaculate blue sky, etc. The enemy tank photos, on the other hand, were all spy photos, not very clear, sometimes fuzzy, etc. And it was these characterstics that the neural net was training on, not the tanks at all. On a bright sunny day, the tanks would do nothing. On an overcast, hazy day, they'd start firing like crazy . . . e. Car that drove across the country Another group of researchers was eventually able to get a car to drive across the country on it's own. They connected a notebook to the controls of the car for output, and they had two cameras mounted to the car's exterior for input. They were eventually able to make it work, but for a while there they had problems. The car would drive along as normal, and then would suddenly spin wildly out of control! They connected this back to shadows on the road. While they thought the car was trained to follow the white and yellow lines of the road, it was actully training on a light and dark contrast between the road and everything else. When a shadow crossed the road, it would go bezerk, because it tried to avoid the darkness. Again, it's important to watch the training of your neural net, and try to figure out exactly what features it's training on . . . Careful what you train on . . . tanks train on background car trains on light and dark and not the lines of the road . . .