introduction to computer science lecture 10: artificial...
TRANSCRIPT
Introduction to Computer ScienceLecture 10: Artificial Intelligence
Tian-Li Yu
Taiwan Evolutionary Intelligence Laboratory (TEIL)Department of Electrical Engineering
National Taiwan University
Slides made by Tian-Li Yu, Jie-Wei Wu, and Chu-Yu Hsu
Tian-Li Yu Artificial Intelligence 1 / 35
What is AI?
Cognitive Science LogicistIs that human?
Think like humans Think rationally
Act like humans Act rationally
Turing (1950) Test
Eliza:chayden.net/eliza/Eliza.html
www.jabberwacky.com
Natural language processingKnowledge representation
Automated reasoningMachine learning
Rational Agent
Tian-Li Yu Artificial Intelligence 2 / 35
Strong AI vs. Weak AI
Weak AI- Machines can be programmed to exhibit intelligent behavior.
Strong AI- Machines can be programmed to possess intelligence and consciousness.
John Searle’s Chinese room argument.
Tian-Li Yu Artificial Intelligence 3 / 35
Levels of Intelligent Behaviors
Reflex: actions are predetermined responses to the input data
More intelligent behavior requires knowledge of the environment and involves suchactivities as:
- Goal seeking- Learning
Tian-Li Yu Artificial Intelligence 4 / 35
Research Approaches in AI
Performance oriented- Engineering track- To maximize the performance of the agents.
Simulation oriented- Theoretical track- To understand how the agents produce responses.
Tian-Li Yu Artificial Intelligence 5 / 35
Understanding Images
Template matching
Image processing- edge enhancement- region finding- smoothing
Image analysis- Hough transformation (line,
circles)
Tian-Li Yu Artificial Intelligence 6 / 35
Natural Language Processing
Syntactic analysis- Mary gave John a birthday card. Subject: Mary- John got a birthday card. Subject: John
Semantic analysis, contextual analysis- John drove me home.- John drove me crazy.
- The pigpen was built by the barn.- The pigpen was built by the farmer.
- Do you know what time it is?
Tian-Li Yu Artificial Intelligence 7 / 35
Natural Language Processing (contd.)
Information retrieval / extraction- I’ve got a solution to your problem.- Shoot.- Right.
- How was your date last night?- He/She has a good personality.
- You can count on me.- Ya, right. That’s comforting.
Tian-Li Yu Artificial Intelligence 8 / 35
Reasoning
Production systems- Collection of states including initial state & goal state(s)- Collection of productions: rules or moves- Each production may have preconditions- Control system: decides which production to apply next
Recall prologSimilar to finite state automata
S1 S2
0
0
11
Tian-Li Yu Artificial Intelligence 9 / 35
Search a Production System
1 2 3
4 6
7 5 8
1 2 3
4 5 6
7 8
1 2 3
4 5 6
7 8
1 2 3
4 5 6
7 8
1 2 3
4 5
7 8 6
1 2
4 5 3
7 8 6
1 2 3
4 5
7 8 6
Goal
Tian-Li Yu Artificial Intelligence 10 / 35
Computer Game Playing
Let’s meet an old friend- Tic-tac-toe
© © ×
×
×
Tian-Li Yu Artificial Intelligence 11 / 35
Game Tree & Minimax Search
O O X
X
O X
O O X
X
O X X
O O X
X X
O X
O O X
X X
O X
O O X
O X X
O X
O O X
X X
O X O
O O X
X X X
O X O
O O X
O X
O X X
O O X
X O
O X X
O O X
X X O
O X X
O O X
X X
OO X
O O X
X X
O X
O
O O X
X X O
O X X
O O X
X X X
O X O
O’s turn (MIN)
O’s turn (MIN)
X’s turn (MAX)
X’s turn (MAX)
0
-1 -1 0
00
0 0
+1 +1
+1+1
-1-1
Tian-Li Yu Artificial Intelligence 12 / 35
Heuristic
For most games, a complete search is practically impossible.- Chess ∼ 1047; Chinese chess ∼ 1048; Go ∼ 10171
A quantitative estimate of the distance to a goal is needed.
Requirements for good heuristics- Much easier to compute than a complete solution- Reasonable estimate of proximity to a goal
Tian-Li Yu Artificial Intelligence 13 / 35
Let’s Define a Heuristic
XX 100X 10
0OX* 0O -10OO -100
© © ×
×
×
−→0+10+10-10+0+10+0+100 = 120
The board favors X
Tian-Li Yu Artificial Intelligence 14 / 35
Does It Work?
O O X
X
X
O O X
X
O X
O O X
O X
X
O O X
X
X O
O O X
X O
X
-80 100 10020
This is the best choice for O based on our heuristic.
Tian-Li Yu Artificial Intelligence 15 / 35
How About This?How About This?
O
O X O X O
X
O
X
O
X
O
X
-10 0 10 -10 -10 0
O X
X
O
O X
X
O
90 100
O X
X
O O
Doomed!!
Tian-Li Yu Artificial Intelligence 16 / 35
What’s Wrong?
Heuristics are not perfect- Otherwise, we’d call them solutions
Heuristics are usually more accurate toward the end of the game.
Need some search procedure for more accurate estimation.
Tian-Li Yu Artificial Intelligence 17 / 35
Heuristic + Minimax Search
O
X
O X
X
O
O X
X
O
O X O
X
O
O X
O X
O
O X
X O
O
O X
X
O O
O X
X
O O
O O X
X
O
O X
O X
O
O X
X
O O
-10 -10 -10
-100 -100
Min: -100
90 0 -180
Min: -180
Max: -100
Tian-Li Yu Artificial Intelligence 18 / 35
Alpha-Beta Pruning
O
X
O X
X
O
O X
X
O
O X O
X
O
O X
O X
O
O X
X O
O
O X
X
O O
O X
X
O O
O O X
X
O
O X
O X
O
O X
X
O O
-10 -10 -10
-100 -100
Min: -100
Not evaluated yet -180
Min: -180
Max: -100
Tian-Li Yu Artificial Intelligence 19 / 35
Learning
Supervised vs. unsupervised
Supervised- Learning by provided examples- Imitation- Parameter tuning
Unsupervised- Learning by experiences- Reinforcement- Evolutionary (semi-supervised)
Tian-Li Yu Artificial Intelligence 20 / 35
Artificial Neural Networks
Human brain- 1011 neurons- 1014 synapses
Tian-Li Yu Artificial Intelligence 21 / 35
Perceptron
-0.5
0
0.5
1
1.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
f(x)
x
-0.5
0
0.5
1
1.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
f(x)
x
w1
v1
v2
v3
w2
w3
Processing unit
Compute effective input:
V1W1+V2W2+V3W3
Compare effective
input to threshold
value.
Produce
output of
0 or 1
1 iff greater than or equal to the thresholdTian-Li Yu Artificial Intelligence 22 / 35
Some Building Blocks
ANDx −→ 1 1.5
1−→
y −→
ORx −→ 1 0.5
1−→
y −→
SIGNx −→ 1 0 −→
Tian-Li Yu Artificial Intelligence 23 / 35
Some Examples
x
y
1
0
0
1
x=2
x −→ 1 2 −→ output
x
y
0
1
x=y
x −→ 1 0-1−→ outputy −→
Tian-Li Yu Artificial Intelligence 24 / 35
The XOR Problem
x
y
1
1
0
0
11.5
1
-1-0.5
-1
x
y
10.5
1output
1 0
1 0
Tian-Li Yu Artificial Intelligence 25 / 35
Associative Memory
Content addressable
.5
.5
.5
.5
.5
.51
1 1
-1
-1-1
-1
-1
-1
1
11 -1.5
Tian-Li Yu Artificial Intelligence 26 / 35
How Does It Worka.
Start: All but the rightmost unitsare excited
b.
Step 1: Only the leftmost unitsremain excited
c.
Step 2: The top and bottom unitsbecome excited
d.
Final: All the units on theperimeter are excited
Tian-Li Yu Artificial Intelligence 27 / 35
Example
BAM applet: http://www.cbu.edu/˜pong/ai/bam/bamapplet.html
Tian-Li Yu Artificial Intelligence 28 / 35
Darwin’s Theory of Evolution
Evolution- The change in populations of organisms over generations.
Darwin’s idea: Natural selection- Struggle to survive- Survival of the fittest- Genetic variation: inherited traits
Tian-Li Yu Artificial Intelligence 29 / 35
Black-Box Optimization
x −→ f −→ y
Finding the x that yields the highest y with an unknown fEvolving the giraffe that is the fittest in an unknown environment.Instead of finding a solution, let’s evolve a solution.
Tian-Li Yu Artificial Intelligence 30 / 35
(1+1) Evolutionary Strategy
Simplest evolutionary strategy
One parent: n-dimension real vector, P = (p1, ...,pn)
Generate one child by mutation: C = (c1, ..., cn)
- ci = pi + N(0, σ2)
Replace P by C if C is better.Modify σ according to the replacement rate r.
- One fifth rule
Tian-Li Yu Artificial Intelligence 31 / 35
1/5 Rule Intuition
σ← σ/C1/n, if r > Θ
σ← σ · C1/n, if r < Θ
If replacement rate high, not exploring enough→ increase step size.
If replacement rate low, too daring→ reduce step size.
Θ = 1/5 (Guessed by Rechenberg) and C = 0.817 (Progress analysis by Schwefel)
Tian-Li Yu Artificial Intelligence 32 / 35
Visualization of 1/5 Rule
σ too small
optimum
contours of
constant f
σ too large
Tian-Li Yu Artificial Intelligence 33 / 35
Training NN with (1+1)ES
x
yo
Target:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++....++++++++++++++++++++++++++...+++++++++++++++++
++++++++++++++++++.......++++++++++++++++++++++++.....++++++++++++++++
+++++++++++++++++.........++++++++++++++++++++++.......+++++++++++++++
++++++++++++++++...........++++++++++++++++++++........+++++++++++++++
++++++++++++++++............++++++++++++++++++..........++++++++++++++
.++++++++++++++.............++++++++++++++++++...........+++++++++++++
..++++++++++++...............++++++++++++++++............+++++++++++++
...++++++++++.................++++++++++++++..............++++++++++++
....++++++++..................++++++++++++++..............++++++++++++
.....++++++....................++++++++++++................+++++++++++
.......++.......................+++++++++++................+++++++++++
................................++++++++++..................++++++++++
.................................++++++++...................++++++++++
..................................++++++.....................+++++++++
...................................++++......................+++++++++
..............................................................++++++++
x
y
o
5 neurons, 17 parameters++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++...+++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++.....++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++.......+++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++........+++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++..........++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++...........+++++++++++++
...++++++++++++++++++++++++++++++++++++++++++............+++++++++++++
..........++++++++++++++++++++++++++++++++++..............++++++++++++
.................++++++++++++++++++++++++++...............++++++++++++
.......................++++++++++++++++++++................+++++++++++
..............................++++++++++++.................+++++++++++
....................................++++....................++++++++++
............................................................++++++++++
.............................................................+++++++++
.............................................................+++++++++
..............................................................++++++++
4 neurons, 18 parameters++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++....++++++++++++++++++++++++++..++++++++++++++++++
+++++++++++++++++++......++++++++++++++++++++++++....+++++++++++++++++
++++++++++++++++++........++++++++++++++++++++++......++++++++++++++++
+++++++++++++++++..........++++++++++++++++++++........+++++++++++++++
.+++++++++++++++............++++++++++++++++++..........++++++++++++++
.++++++++++++++.............++++++++++++++++++..........++++++++++++++
..++++++++++++...............++++++++++++++++............+++++++++++++
...++++++++++.................++++++++++++++..............++++++++++++
....++++++++..................++++++++++++++..............++++++++++++
.....++++++....................++++++++++++................+++++++++++
......+++.......................++++++++++..................++++++++++
................................++++++++++..................++++++++++
.................................++++++++....................+++++++++
..................................++++++......................++++++++
...................................++++.......................++++++++
....................................++.........................+++++++
Total Differences: 172(123.084600)/1540
Tian-Li Yu Artificial Intelligence 34 / 35
License
Page File Licensing Source/ author
28”BAM applet”.,Author:[email protected], Source: http://
dilbert.com/strips/comic/1996-05-02/, Date:2013/03/06, Fairuse under copyright law 46,52,65.
6
”Edge detection applied to a photograph”.,Author:JonMcLoone, Source: http://en.wikipedia.org/wiki/
File:EdgeDetectionMathematica.png, Date:2013/03/06, This workis licensed under the Creative Commons Attribution-ShareAlike 3.0 Li-cense.
Tian-Li Yu Artificial Intelligence 35 / 35