1.2: Models, Goals, And Learning

What Is Intelligence, Really???

“I keep trying to explain to people that the archetype of intelligence is not Dustin Hoffman in ‘The Rain Man’, it is a human being, period.” — Eliezer Yudkowsky

There’s a lot of complex factors involved in intelligence. Just holding a conversation involves a plethora of flexible, general skills: task prioritization, abstract reasoning, synthesizing relevant information, and maybe even creativity … Yet despite all this, intelligence can be summarized in just three words.

Goal-directed behavior.

Whether it’s driving a car or designing rockets, making small talk or inspiring nations, musing about yesterday’s lunch or introspecting on the meaning of life — all the multifaceted, dizzyingly intricate behaviors that we exhibit are in furtherance of our goals and values. Some of these goals are implicit, some are explicit, but they are always there. We think because we care; otherwise, why even bother?

We define artificial intelligence in much the same way as the real kind; programs that effectively work towards accomplishing their goals. Ultimately, the only AI worthy of the moniker “intelligent” is one that succeeds.

The Rollercoaster Test

Successful AI programs tend to involve three main components: modeling, goal evaluation, and learning.

Understanding this paradigm is central to learning to write useful deep learning code — in fact, we’re probably going to use it in every program in this course. So, for practice, we’ll start with an example that’s both (laughably) simple and (hopefully) memorable.

Yeah, you guessed it. We’re going to try and predict whether a given person, with height H, can get onto a rollercoaster. Using a “dataset” composed of the fortunate people who got in … and the vertically-challenged people who didn’t make it.

Hello, my old friend.

There’s probably a number of questions that are running through your mind right now. Like, “In what vanishingly strange, speculative scenario would this be useful?” Or, “Why not just walk up to the sign and look at it?”. *Or, *“Is it possible to get a refund on a free online course?”

But in time, all your questions will be answered. In time, you’ll learn what every true AI researcher knows: the simple pleasure of forcing smart computers to do very stupid things.

So pull up Python, open a new file and let’s get to coding!

Modeling

“All models are wrong, but only some are useful.” — George Box

The first thing every AI needs is some sort of model of the world around it. An initial hypothesis about the nature of the data that it manipulates. This model doesn’t need to be right, or even close to right. However, it does need to have the possibility of being adjusted and modified to correctness.

Every task requires its own unique type of model. For example, a geographical map would be useful for a self-driving car, but far less useful for a music generation engine.

For this specific problem, our model is absurdly simple. It is parametrized by a single value, $H$, and predicts that people will only be let on the rollercoaster if they are taller than the threshold ($h \geq H$).*

# Returns predictions for array of input heights
def predict(H, data):
return [height > H for height in data]


Goal Evaluation

“Intelligence without ambition is a bird without wings.” — Salvador Dali

Every machine learning task involves goals. Some goals are all-or-nothing, but for most objectives it is entirely possible to make steady progress towards success, without necessarily reaching it. Evaluation metrics give you a measure of this progress.

For this specific task, our goal is simple: correctly predict whether various children are allowed on the rollercoaster. We need a dataset of examples, as well as a simple Python function to measure our prediction accuracy for each value of $H$.

# We definitely did not make up this data on the fly
# It was collected through rigorous experimentation

heights = [20, 35, 42, 45, 46, 49, 60]
allowed = [False, False, False, True, True, True, True]

# Evaluates and returns the current model accuracy
def evaluate(H):
predictions = predict(H, heights)
num_correct = 0
for prediction, target in zip(predictions, allowed):
if prediction == target: num_correct += 1
accuracy = 100.0*num_correct/\len(allowed)
return accuracy


Learning

The last and final step we need is the learning phase, in which our model is iteratively corrected to become more and more accurate. Learning is always finicky: you need to strike a balance between exploration — trying a bunch of diverse model configurations — and exploitation — homing in on one specific configuration that works well.

In this specific case, the state space is so small that we can use a simple uniform search to find the optimum threshold $H$. We just start at the lowest possible threshold ($0$) and increase by increments of ($1$), recording the value of $H$ that achieves the highest accuracy.

best_H = 0
best_accuracy = 0.0

for H in range(0, 100):
accuracy = evaluate(H=H)
print (H, accuracy)
if accuracy > best_accuracy:
best_accuracy = accuracy

print ("Best threshold: ", best_H)
print ("Best accuracy: ", best_accuracy)


Putting It All Together

We can now run our program and use it to find the optimum value of $H$ — that is, the threshold value that fits the dataset the best. This results in a “model” that can easily predict whether new riders will be allowed on the rollercoaster or not.


# Returns predictions for array of input heights
def predict(H, data):
return [height > H for height in data]

heights = [20, 35, 42, 45, 46, 49, 60]
allowed = [False, False, False, True, True, True, True]

# Evaluates and returns the current model accuracy
def evaluate(H):
predictions = predict(H, heights)
num_correct = 0
for prediction, target in zip(predictions, allowed):
if prediction == target: num_correct += 1
accuracy = 100.0*num_correct/len(allowed)
return accuracy

best_H = 0
best_accuracy = 0.0

for H in range(0, 100):
accuracy = evaluate(H=H)
print (H, accuracy)
if accuracy > best_accuracy:
best_accuracy = accuracy
best_H = H

print ("Best threshold: ", best_H)
print ("Best accuracy: ", best_accuracy)


It works! We find that using a threshold of 45, we can get 100% accuracy in predicting who will be let on the coaster.

1.1: Setup

This course requires Python3, numpy, matplotlib, seaborn, and torch (PyTorch). More information will be here shortly: setup is always essential!

Why Artificial Intelligence?

You’ve heard the hype about artificial intelligence.

Billions of dollars in VC funding are flowing yearly to Silicon Valley startups attempting to use AI to revolutionize fields from healthcare to manufacturing to contract law to cybernetics. The fastest supercomputers in the world are being harnessed to run massively-parallel, ever-larger “deep neural networks”. Hundreds of breathless journalists report on the newest research advances.

And then there’s the thinkpieces, full of bold claims and futuristic speculation. AI will cure world hunger. AI will take over everyone’s jobs and make us all obsolete. AI will usher in a new era of global consciousness and immanentize the eschaton. AI is…the Next Big Thing.

Probably plotting to take over your job right now. And the world.

So, the question is — why? Why is everyone so excited about artificial intelligence? What’s behind the big AI boom? And can you use AI to tackle practical challenges— not 20 years in the future, but today?

Insight #1: (Narrow) AI is all around you.

A common misconception about artificial intelligence is that it is a thing of the future. As John McCarthy — one of the founders of the field — famously complained,

“as soon as it works, no one calls it AI anymore.”

In fact, we are surrounded by “narrow” artificial intelligences that make our lives easier and save us time in innumerable ways — though we don’t usually think of them as AI.

Phone bots, on the other hand, are just examples of artificial stupidity.

“Software is eating the world, but AI is going to eat software.” — Jensen Huang, Nvidia CEO

As these tools become increasingly flexible, we’ll give them far more responsibility. Pilot drivers for Waymo (formerly Google’s self-driving car project) and Tesla Autopilot already trust their lives to software. In the end, the seductive allure of using tools that make us faster and automate away drudgery can never be underestimated, especially when there’s just so much drudgery to be automated —- in medicine and in law, at work and at home, in the virtual and in the physical world.

Insight #2: (Deep) AI is smarter than you.

Yet while some people build programs to do what humans won’t, others dream of creating intelligences that do what we can’t. Of course, we’ve been building technology to rectify our faults for millennia. But with the power of deep learning — a newly-popular subfield of machine learning and AI — we can achieve a whole lot more.

Deep learning involves incredibly complex, abstract mathematical structures called “neural networks”; these networks look vaguely reminiscent of the human brain and can be taught to predict, classify, or generate almost anything. (If you stick with this course, you’ll learn far more about deep learning, but for now we’ll leave it at that.)

With enough computational power, deep neural networks can surpass humans on many intellectual battlegrounds. The famous AlphaGo versus Lee Sedol matches showed this decisively, with Google’s self-trained AI handily beating the reigning world champion in Go, an ancient Chinese strategy game of immense complexity.

Professional Go player Lee Sedol playing against Google’s AlphaGo (source: AI Business). Go was once thought impossible for machines to play: it has more board positions ($10^{170}$) than there are atoms in the universe.

On the right tasks, these networks can also show glimmers of genuine creativity. Writing suitable captions for thousands of images based on their content. Generating almost-readable Shakespeare plays. Composing in the style of Beethoven or Bach. Bluffing like the pros in Texas Hold’ Em.

Left: Google’s DeepMind’s image captioning system. Right: a sample of Shakespeare generated using char-rnn. It makes more sense than Hamlet did to me :(

But perhaps more interesting is when deep learning helps us augment our understanding and our reach in exponential ways. Through, for example, detecting subtle cellular patterns in vast microscopy images, patterns that can profile tumors more accurately than physicians every could. Or developing generative models to forecast the morphology and formation of galaxies.

Left: Nvidia’s cell tissue segmentation methods. Right: galaxy reconstruction using generative adversarial networks (GANs).

When neural networks help you understand the secrets of life and the poetry of the stars, it becomes hard to deny that there’s real intelligence behind the complex computations. Intelligence that could help us in the same ways that narrow AI currently helps us, except exponentially more effectively.

No wonder people are excited.