Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CS221: Introduction To Artificial Intelligence

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 122

CS221: Introduction to

Artificial Intelligence
http://cs221.stanford.edu/
Candy Policy
CS221 Staff

Get to know us!


Right Course?

Maths of Computing (CS103)

Programming (CS106)

Probability
Summertime?
Due Dates

• Due at 11:59P.M.

• Three free “late days”

• Extensions approved by Chris.


Grading Scale
Homework and problem set grades for the assignments use the
following scale:

A submission so good it “makes you weep.”

Exceeds requirements.

Satisfies all requirements of the assignment.

Meets most requirements, but with some problems.

Has more serious problems.

Is even worse than that.

Why did you turn this in?


Grade Breakdown
Ask Questions!

Post to Piazza

Email cs221-sum1213-
staff@lists.stanford.edu

10
Book

$78

Prime
Homework 1

Due July 8th

Python review Friday 2:15


to 3:05pm in Gates B01

12
Honor Code Rules

Rule 1: You must indicate on your submission any assistance


you received.
Rule 2: You must not share actual program code or problem
solutions with other students.
Rule 3: You must not look at solutions posted on the web or
from other years.
Rule 4: You must be prepared to explain any homework you
submit.
What is AI?
[suspense]
AI: The study and design of intelligent agents
Volunteer
AI: The study and design of intelligent agents
Computer
programs

AI: The study and design of intelligent agents

Better than As well as


chance humans
A Brief History
Early Optimism (1950s)

1952 1955
Early Optimism (1950s)
Underwhelming Results (1950 to 90s)

Problem space grew too quickly

Complexity of the world made it hard to encode all rules


Data Revolution (1990s)

Use data to learn from experience

Model Uncertainty
Big Milestones

1997 Deep Blue

2005 Stanley

2011 Watson
Exciting Times!
CS221

Search
Machine
Learning
Variable
Based
Course Goals
Reason about goals: what will I get if I try this
sequence of actions?

Deal with uncertainty: don't know what will happen,


ambiguity in language, noise in sensor readings

Learn from experience: results of actions provide


information to improve utility over time

Solve real problems: formalize real life challenges


and know a few tools to solve formalized problems.
The AI Pipeline

Real World Problem

Model the problem

Formal Problem

Apply an Algorithm

Evaluate Solution
Ready to dive in?

Footer Text 30
4/26/2019
Searching:
Using AI algorithms to find
solutions for you.
DNA Alignment

ATTGGGAAATGCCCCATTATTBBC

ATTGGAATCGACATATTATTBBC
DNA Alignment
CS221

Search
Machine
Learning
Variable
Based
CS221

Search

Model how to make decisions. Have an algorithm


learn which decision(s) can lead to a “solution”
Determ. State Problems

Model

Solvers
Determ. State Problems

Model

Solvers
Deterministic State Problems

No Uncertainty Discretized
Deterministic State Problems
Maze
Maze


Maze == Ghost Algorithm
Determ. State Problems

Model

Solvers
Determ. State Problems

Model

Solvers
The AI Pipeline

Real World Problem

Model the problem

Formal Problem

Apply an Algorithm

Evaluate Solution
Deterministic State Space Models
State

A state contains all information that is


(i) Not – constant
(ii) Relevant to the task
State

• Position • PI (3.14)
• Direction • Price of gold
• Position of
other
Airplanes
Intuition
Intuition

Describe how a computer


can try everything
Intermission

http://vimeo.com/65042779
Spell Checking
Knight’s Tour

Knight's Tour Demo


Knight’s Tour
Determ. State Problems

Model

Solvers
Determ. State Problems

Model

Solvers
The AI Pipeline

Real World Problem

Model the problem

Formal Problem

Apply an Algorithm

Evaluate Solution
Exploration Algorithm

Start
Goal
Breadth First Search

Insight: Keep a
queue of states to
visit
Breadth First Search

queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search

queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search

queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search

Enqueue the start state


Breadth First Search

Dequeue the first state


Breadth First Search

Check if it’s the goal or if it has been visited


Breadth First Search

Find each successor state


Breadth First Search

Front Back

Find each successor state


Breadth First Search

Find each successor state


Hashing Breadth First Search

Enqueue the successor states


Hashing Breadth First Search

Enqueue the successor states


Breadth
Breadth First SearchFirst Search

Forget about the dequeued state


Breadth
Breadth First SearchFirst Search

Back to the start of the while loop


Breadth First Search

Dequeue a state
Breadth First Search

Check if it’s a goal or if the state has been visited


Breadth First Search

Find each successor state


Breadth First Search

Enqueue each successor


Breadth First Search

Enqueue each successor


Breadth First Search

Back to the start of the while loop


Breadth First Search

Dequeue a path
Breadth First Search

Check if it’s a goal


Breadth First Search

queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Depth First Search

stack = Stack()
stack.push(startNode)
visited = Set([])
while !stack.isEmpty():
currState = stack.pop()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
stack.push(nextState)
}
}
}
Stack vs Queue
Stacks

LIFO

push and pop

Dish metaphor
Depth First Search

Create an empty stack


Depth First Search

Push a path with just the start node


Depth First Search

Enter the while loop


Depth First Search

Pop a path
Depth First Search

Check if its been visited or if it’s the goal


Depth First Search

Create a path for each of its neighbors


Depth First Search

Bottom Top

Create a path for each of its neighbors


Depth First Search

Create a path for each of its neighbors


Depth First Search

Push the new paths


Depth First Search

Push the new paths


Depth First Search

Back to the start of the while loop


Depth First Search

Bottom Top

Back to the start of the while loop


Depth First Search

Pop a path
Depth First Search

Check if the last node is a goal or if its been visited


Depth First Search

Create a new path for each neighbor of the last node


Depth First Search

Push the new paths


Depth First Search

Push the new paths


Depth First Search

Back to the start of the while loop


Depth First Search

Pop a path
Depth First Search

Check if the last node is a goal or if its been visited


Depth First Search Pros

If you implement depth first


search recursively it only has to
store a single path in memory! BFS
must store all states in the fringe.
Depth First Search Cons

Not guaranteed to find the lowest


cost solution for all problems.

Can get lost.


BFS vs DFS

Demo
DNA Alignment

ATTGGGAAATGCCCCATTATTBBC

ATTGGAATCGACATATTATTBBC
Can We Do It?
We Broke BFS
Why AI?
Why AI?
Why AI?
Why AI?
Determ. State Problems

Model

Solvers
Computer
programs

AI: The study and design of intelligent agents

Better than As well as


chance humans
The End.
The End?

You might also like