Tuesday, September 28, 2010

Understanding Neural Networks

Neural networks are deceptively simple and yet subtly complex.  Even this simple three-layer network can produce startling results.  Now imagine your brain with billions of such nodes - and what it is capable of.

The human brain doesn't come with an operating manual.  And yet, understanding how your brain works is important if you are to avoid some of the major pitfalls in life.

Your brain is a highly complex neural network, of which the diagram above is a very simple example.  What is a neural network?  Basically, it is a learning computer.  A series of nodes are connected together in layers, with an input (stimuli) entering one end, and an output (action) coming from the other.  Each node accepts a signal from a previous layer, and then outputs another signal, multiplied by a weighting factor.

To "program" a neural network, you set initial weighting factors to the nodes and then "train" the network with sample inputs (stimuli) and then look at the outputs (actions) and then use them to modify the weighting factors to alter the output to a desired result.  Over time, with additional training, the network "learns" to output the desired result, and is then considered programmed.

One of the early test applications of neural networks was to use such a network to distinguish between male and female faces.  An image recognition network was designed and then "trained" on a series of sample facial images, to distinguish whether they were "male" or "female".  The network learned quickly and once trained with the sample images, could distinguish subsequent images with a high level of probability.

Now think about this a second - the computer was not "told" what to look for in the images as "male" and "female" characteristics.  It was just given a sample set to learn from, and then the network determined what was "female" and "male".  In a way it is a little spooky, but in a way, it is exactly how your brain works.

Think about it.  You can recognize a "male" or "female" face in a second, but if I asked you to tell me how you can tell it is male or female, you would have to think for minutes of a list of distinguishing features that you could cognitively recite.  And if you programmed that list of features into a traditional digital computer, it would get the recognition wrong half the time.  No, you recognize "male" and "female" faces instantly, as your brain is programmed to recognize them.  You do not look at a face and check off a list of features and then make a decision.

And this brings us to the first observation about how your brain works, by the way.  It turns out that facial recognition is not a trivial function of the brain, but one of its main functions.  As discussed recently in a New Yorker article, facial recognition can be tied to a particular part of the brain.  And if that part is damaged, people have trouble recognizing faces.  Facial recognition was no doubt important to our early ancestors, for whom recognition of "friend or foe" (a military term, which will crop up later in this report) was a matter of life or death.  Our brains are literally programmed to recognize faces.

And this is one reason why we tend to see faces in things.  A mound of dirt on Mars looks like a face, so we say there is a "Mars Face" and people run off to create paranoid theories about how NASA is suppressing lost civilizations of Martians.  Or people see the face of Jesus or Mary in a taco or a shirt stain, and suddenly, it is a "miracle" and people flock to pray to the taco.  But in reality, it is just that our brains are programmed to "see" faces, and in particular, look for familiar faces.  Think about this for a second - how you can scan a crowd of people and see a familiar face among thousands, almost instantly.  Neural networks are powerful computers.

We even see "faces" in inanimate objects.  Cars, for example, have "faces" we recognize, and often the styling of the car produces a "face" that is either happy, aggressive, or aloof, depending on whether you are trying to sell a car that looks fun, sporty, or luxurious.

So the first observation to take away from this, is to understand how you perceive things in life.  Seeing  a face on Mars or on a taco is no cause for alarm, but a side-effect of how your brain works.  Running off and starting a blog about NASA suppressing evidence of a race of lost Martians makes no more sense than saying that GM has suppressed a long-lost race of '55 Chevies.  Just because something has a face on it, doesn't make it alive - or a miracle.

OK, you say, the human brain is this huge face-recognition neural network.  How does this help my finances?  Well, bear with me, because like any complex idea, this gets complicated.

One of the early applications (and misadventures) involving neural networks, was the attempt by the military to use neural networks for image recognition.  The military wanted a way to program a missile to identify American or Soviet tanks ("Identify Friend or Foe") and then target only Soviet tanks.  They hoped to use this technology in the Maverick Missile, which you may recall "60 Minutes" did a show on.

So they did the usual - designed an image-recognition software and programmed it with sample pictures of Soviet and American tanks until the network appeared to be able to distinguish between the two.  Then they installed this network in a Maverick Missile and took it to the firing range and.... fiasco!

What happened?  It all worked so well in the lab!  Well, later analysis revealed that the photos used to train the network were at fault. The images of the US tanks were all "beauty shots" from the manufacturer, in full light, showing off the Abrams M1A1 in all its glory.  The photos of the Soviet tanks, on the other hand, were dimly lit spy photos or other clandestinely obtained photographs.  From this, the missile "learned" to go after poorly lit tanks, regardless of nationality.

So what do we learn from this?  A big lesson.  When you program a neural network, you may think you are teaching it one thing, but it may be learning another, entirely different lesson.  If you are parents of a teenager or if you are a school teacher, well, you probably know first hand how this works.  You try to teach a teen one thing - by setting up a system of rules and feedback - and they learn another thing entirely - how to beat your system!

So you have to be very careful when trying to train others - or even yourself, that your feedback is precise enough that you are not mis-programming your brain as a result.  You may think you are learning one thing, but your brain, deep down, is learning another.  You set up a system, such as production goals at work or grades at school, and some folks may "learn" to get positive feedback from the system.  Others just "learn" how to game the system, identifying poorly lit tanks, instead of Soviet ones.  And oftentimes, the gamers seem to come out ahead, at least initially, until they are put into battle and get everything wrong.

Feedback is one of the keys.  We tend to emphasize some positive results and attenuate negative ones.  Thus, for example, the gambler remembers winning and forgets about losing.  As a result, his brain becomes programmed to "learn" gambling, by providing positive feedback from wins, while not adjusting those weighting factors from losing.  In fact, if you watch people gambling, particularly with slot machines, it may remind you of the Skinner Box experiments, where rats press levers repeatedly until they receive a reward.  The rats learn from the lever press than generates the reward, not from the repeated presses that do not.  Eventually, you can "program" the rat to press a lever 5,000 times to get a food pellet.

Similarly, people will "learn" to get the high from drugs, while ignoring the negative feedback produced by the drug lifestyle.  They will "learn" to enjoy having shiny products by financing them on time, and attenuate the negative feedback from years of payments, onerous financing terms, and perpetual poverty such spending habits produce.

The common denominator, it seems, is that positive feedback programs our brains far more than negative.  And again, this is probably a survival skill for the species.  In the wild, we learn quickly to avoid danger (negative feedback) - that is, provided we survive it.  But an animal that is constantly avoiding danger cannot reap a reward (food) without going out and looking for it.  So while the negative feedback from danger may make a deer wary, they still venture out, in hunting season, to find food.  Otherwise they'd starve to death.

So applying this to personal finances, we see that the consumer is at a disadvantage from the get-go.  All of our financial experiences in life are designed to promote positive feedback.   We are drawn to shiny and new, even though the cost is high.  We buy things to please ourselves, without thinking of the real cost over time.  And we tend to trivialize or forget our mistakes (and go right back and repeat them, again and again, expecting different results!) while at the same time amplifying what we perceive to be rewards.

To succeed financially, you have to cognitively analyze your finances - try to break down what makes a face male or female, so to speak, rather than merely use facial recognition.  In other words, you have to rely less on impulse and more on analysis.  The only exception to this, I think, is when you have a "gut reaction" that is negative.  As negative feedbacks are attenuated to a level far less than positive ones, you have to listen to negative feedback a lot more.

For example, when you are at the used car showroom, and the salesman in the loud plaid suit is trying to sell you a shiny used sports car for $5000 over book value, you may be getting two types of feedback.  Part of your brain is saying "shiny! shiny! New car!  Whee!" and is ready to sign the papers on any sort of onerous deal.  But another part is saying, quietly, "I don't like this, I don't trust this person.  Something is not right here!"  Listening to that quieter voice is perhaps the key.

And perhaps in popular culture, this is reflected as the two sides of our nature - the "angel" and "devil" sitting on our shoulders.  And which one do we listen to more often?

Another important aspect of neural networks that we can apply to our own lives is that they continually learn over time.  Each piece of feedback reprograms the weighting factors on the network - perhaps slightly, as the network "zeros in" on a desired feedback.  But over time, as the stimulus (input) changes, these weighting factors can change substantially.  In effect, your brain is reprogramming itself over time.  You - and your personality - are constantly changing.

You may notice this (and I have written about this before) when you go to a high school reunion, or meet up with an old friend on Facebook.  You may have been "tight" with a friend in college - hanging out with them all the time, completing each other's sentences, and generally tuning into the same wavelength.  But 30 years pass - 30 years in which you have had dramatically different life experiences.  Suddenly its like, "You've changed, man!" and that person no longer seems the same to you (or you to them).

Long periods apart may cause people to drift apart, only because their intervening life experiences are different.  The longer and more different their lives are, the less likely they will connect later on in life.  So long-distance romances are hard to keep up, once you live in different States and have different life experiences.  And when two people are separated for long periods of time, it may be hard to get back together.  A veteran returning from the horrors of war may find it hard, initially, to "connect" with a spouse back home, whose life has been dramatically different in the intervening months and years.  This is normal - to be expected - not an anomaly.

This would suggest also that the more time you do spend with someone after a separation like that, the better the chance you will stay together - as you both reprogram your brains with common experiences.

The good news you can take away from all of this is that your brain CAN be reprogrammed with proper training and stimulus.  Of course, the older you are, the harder it is to "retrain your brain" as the nodes in your network have been continually programmed over the years with old data.  Teaching an old dog new tricks is indeed hard, but not impossible, as the saying would lead you to believe.

So, if you can retrain yourself to find more substantial rewards in financial behavior, you may be able to improve your financial condition.  Finding a "reward" in having a balance in your bank account rather than a shiny object parked in your driveway will mean you are ultimately happier down the road.  If you can learn to avoid the adrenaline rush of the gambler, you may be able to reprogram your brain to avoid that ruinous habit.  It is possible to change your brain, although granted, it is not easy.

Neural Network theory is being applied more and more in technology today.  Many newer cars have neural network computers that "learn" shifting or engine management.  Software can crawl the web looking for data and "learn" what results are desired.  Applications for this technology are ever-increasing.  And in terms of understanding the human brain, neural network theory may revolutionize the fields of psychology and psychiatry by replacing antiquated ideas with a more scientific understanding of how the brain functions at a network level.

Understanding your own brain, and how it works, will help you understand your motivations - both good and bad - and help you lead a better life.  And I think understanding Neural Network Theory is a key to understanding your brain.