A I 2020 Discussion 1105
A I 2020 Discussion 1105
• 9/17, 9/24
• 10/8, 10/15, 10/22, 10/29
• 11/5
AI Hype
September 17, 2020
Data Driven
(ML, DL, …)
Knowledge
Based
Graduate Course
• Basics of AI
– Prolog as exercises
• Exploring your own interest
– Research in AI technologies
– Research in AI applications (in your field)
– AI techniques (like ML, DL, …)
• Results
– Survey paper
– System development
Textbook
• Ordering the textbook (AIMA book): NT1230
• Reading assignment
– Chapter 1 & Chapter 2
– https://people.eecs.berkeley.edu/~russell/aima1e/chapter01.pdf
– https://people.eecs.berkeley.edu/~russell/aima1e/chapter02.pdf
September 24, 2020
Assignments
• Lecture
– Read Textbook Chapter 3
• Survey paper
– Start explore what you want to write for a survey paper
– Collect related papers
– Propose possible topics by October 15
October 8, 2020
A Simple Example
8 possible slots
Rules
vs.
Machine
Learning
9 x 8 x 7 x … x 1 = 9!
362880 possible slots
10
Search Strategies
• Breadth-first search
• Depth-first search
Tic-Tac-Toe
Breadth-first search
Tic-Tac-Toe
Depth-first search
Tic-Tac-Toe
Heuristic search
科技大擂台 與AI對話(熱身賽)
https://fgc.stpi.narl.org.tw/activity/techai
科技大擂台 與AI對話(熱身賽)
• 線上教學 教學文件
– https://fgc.stpi.narl.org.tw/activity/video/techai
• TensorFlow
– https://www.tensorflow.org/
– https://www.tensorflow.org/tutorials/quickstart/beginner
• Keras
– https://keras.io/
• PyTorch
– https://pytorch.org/
• Kaggle
– https://www.kaggle.com/
Assignments
• Read Chapter 4
• Pick a machine learning or deep learning tool to gain some
experience
October 15, 2020
State Search
• Variety of uninformed search strategies
– Breadth First Search, Depth first Search, Iterative Deepening Search
• Problem formulation usually
– Modeling: abstraction into state space
• Graph search can be exponentially more efficient than tree
search
Figure 3.21
Summary of Algorithms
Chatbots
• Loebner Prize Winners
– https://aisb.org.uk/category/loebner-prize/
– https://aisb.org.uk/aisb-events/
– None of the chatbots competing in the finals managed to fool a judge into
believing it was human. The judges ranked the chatbots according to how
human-like they were. Scores out of 100% were:
• Mitsuku 33%, Tutor 30%, Colombina 25%, Uberbot 23%
– Past winners
• Mitsuku: https://www.pandorabots.com/mitsuku/
• A.L.I.C.E vs. Jabberwacky https://www.discovermagazine.com/technology/i-chat-
therefore-i-am
• https://www.chatbots.org/
Challenge in Real Use
https://www.chatbots.org/conversational/agent/chatbots.org_report_consumers_chatbot_usage_uk_us/
https://outlook.stpi.narl.org.tw/mailapp/load?arhId=4b1141006e7eb85a016e818390ad027c&mabId=4
b1141006e7eb85a016e818582430285&madId=4b1141dd6bf14de5016bf4b00fce610a
teaching(alan, ai).
?- teaching(alan,X).
taking(angga, ai).
?- taking(rax,X).
taking(rax, ai).
?- taking(X,Y).
student_of(X,Y) :-
teaching(X,Z), ?- student_of(alan,Y).
taking(Y,Z).
No TAB allowed
Semantic Nets
• Used for propositional information (information that is either
true or false)
• Propositional net
• Declarative knowledge
• Labeled directed graph
• Nodes (objects) and arcs (links/edges)
Joseph Giarratano and Gary Riley, Expert Systems: Principles and Programming, Course Technology, 4th ed., 2005.
Semantic Nets (cont.)
Semantic Nets (cont.)
Initial Design Warning: not
quite working
• mother_of(susan, john).
• wife_of(susan, tom).
• father_of(tom, john).
• husband_of(tom, susan).
• mother_of(ann, susan).
• wife_of(ann, bill).
• sister_of(ann, carol).
• father_of(bill, susan).
• husband_of(bill, ann).
Predicate Definitions
• mother_of(susan, john).
• mother_of(ann, susan).
• wife_of(susan, tom).
• wife_of(ann, bill).
• father_of(tom, john).
• father_of(bill, susan).
• husband_of(tom, susan).
• husband_of(bill, ann).
• sister_of(ann, carol).
Basics
• To start at powershell or cmd
– swipl
• Within the SWI Prolog environment
– To read a file (file extension .pl)
• [finalname].
– To quit
• halt.
– To get another answer (binding different value to variable)
• ;
– To turn off the warning color
• set_prolog_flag(color_term, false).
Basic Operations in Family Tree Example
• [family2]. mother_of(susan, john).
mother_of(ann, susan).
• mother_of(susan, X).
wife_of(susan, tom).
• mother_of(X, john). wife_of(ann, bill).
• mother_of(X, Y). father_of(tom, john).
father_of(bill, susan).
husband_of(tom, susan).
husband_of(bill, ann).
sister_of(ann, carol).
Little Tricks
• dynamic
– dynamic mother_of/2.
• assert
– assert(mother_of(carol,tom)).
Prolog
• SWI Prolog
– http://www.swi-prolog.org/
• Prolog tutorial
– https://www.cpp.edu/~jrfisher/www/prolog_tutorial/contents.html
– http://ccckmit.wikidot.com/ai:prolog
– http://programmermagazine.github.io/201308/htm/article3.html
– https://en.wikibooks.org/wiki/Prolog
– http://www.cse.unsw.edu.au/~billw/prologdict.html
• Insight on learning Prolog
– https://www.ithome.com.tw/voice/110557
– https://kknews.cc/zh-tw/tech/gqralpy.html
• Online book
– https://www.metalevel.at/prolog
Original
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html
Map Coloring
adjacent(1,2). adjacent(2,1).
adjacent(1,3). adjacent(3,1). conflict(Coloring) :-
adjacent(1,4). adjacent(4,1). adjacent(X,Y),
adjacent(1,5). adjacent(5,1). color(X,Color,Coloring),
adjacent(2,3). adjacent(3,2). color(Y,Color,Coloring).
adjacent(2,4). adjacent(4,2).
adjacent(3,4). adjacent(4,3). ?- conflict(a).
adjacent(4,5). adjacent(5,4). false.
factorial(N,F) :-
N>0,
N1 is N-1,
factorial(N1,F1),
F is N * F1.
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_2.html
Tower of Hanoi
move(1,X,Y,_) :-
write('Move top disk from '),
write(X),
write(' to '),
write(Y),
nl.
move(N,X,Y,Z) :-
N>1, ?- move(1,left,right,center).
M is N-1,
move(M,X,Z,Y), ?- move(2,left,right,center).
move(1,X,Y,_),
move(M,Z,Y,X). ?- move(3,left,right,center).
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_3.html
Challenges
• Build your own family tree for over 20 people and 4 generations.
– Either yours or some famous people.
– Define some new relationships other than the basic ones.
– Try to come up with some “missions” that you could do with your
knowledge.
– Explain your achievement.
– Due: October 16 (posting on ecourse2)
• Try some tools mentioned by MOST or other tools
– https://fgc.stpi.narl.org.tw/activity/video/techai
– Due: October 30 to decide which tool to study
– Due: December 2 to demo an example
October 29, 2020
Search and Beyond Search
• State search
– Breadth first search, depth first search, iterative deepening search
– Greedy search, A* search
• Searching the unsearchable (because of the size of combinations of
states)
– Hill-climbing
– Simulated annealing, local beam, genetic algorithm
– Optimization algorithms like evolutional and metaheuristics algorithms
• More challenges (less information)
– Non-deterministic
– Partially observable
– Online search
Challenges for Prolog and ML/DL
• Build your own family tree for over 20 people and 4 generations.
– Either yours or some famous people.
– Define some new relationships other than the basic ones.
– Try to come up with some “missions” that you could do with your knowledge.
– Explain your achievement.
– Due: November 16 (posting on ecourse2)
• Try some tools mentioned by MOST
– https://fgc.stpi.narl.org.tw/activity/video/techai
– TensorFlow https://www.tensorflow.org/ https://www.tensorflow.org/tutorials
– Keras https://keras.io/
– PyTorch https://pytorch.org/
– Kaggle https://www.kaggle.com/
– Google colab https://colab.research.google.com/notebooks
– Due: November 4 to decide which tool to study
– Due: December 10 to demo an example
Grading Criteria
• Programming assignments 10%
• Report on a research topic 20%
– Presentation
– Written report
• Project 25%
– System development
– Progress report
– “ecourse2” discussion board
• Quiz 15%
• Final examination 30%
Report Assignments
• Paper + Presentation
• Topic (both)
– AI research
• Techniques and trends
– AI application in any field
• Content
– At least 4000 words
– At least 6 references
• Due date
– December 24 & 31 (presentation)
– January 11 (report): 100%
– January 18 (report): 90% or 500 more words for 100%
Term Paper Presentation
• Purpose of literature survey
– To investigate what’s going on in a research field
– To compare the related papers and discuss the similarities and differences along with
pros and cons
– To observe from the result
• What are the trends? What to avoid? What are new topics? …
• Content of presentation
– Describe and explain your topic
– List at least six related papers you have gathered and prepare to read (or have read)
• Be sure to use a correct and consistent citation format, i.e. IEEE or ACM
• You may state a portion of the abstract under the paper title
– Describe each paper
– Describe the expected results
• Why you have chosen such papers and what you want to compare?
• What do you expect to see?
Written Exams
• Quiz 1 (Nov. 5 or 12??)
– Ch.3 Searching techniques
– Ch.4 Local search
• Quiz 2 (Nov. 26 or Dec. 3??)
– Ch.5 Adversarial search
– Ch.6 Constraint satisfaction problem
• Final examination 30% (Jan. 7) 90-min exam
– Ch.7 ~ Ch.9 Logic and inference
– Ch.10 Planning
– Ch.14 Probabilistic reasoning*
– Ch.18 Learning*
– Something missed in quizzes
Prolog
Lists and Sequences
member(X,[X|R]).
member(X,[Y|R]) :- member(X,R).
?- member(2, [1,2,3]).
?- member(X, [1,2,3]).
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_7.html
Lists and Sequences (cont.)
takeout(X,[X|R],R).
takeout(X,[F|R],[F|S]) :- takeout(X,R,S).
reverse([X|Y],Z,W) :- reverse(Y,[X|Z],W).
reverse([],X,X).
reverse(A,R) :- reverse(A,[],R).
Lists and Sequences (cont.)
mergesort([],[]).
mergesort([A],[A]).
mergesort([A,B|R],S) :-
split([A,B|R],L1,L2),
mergesort(L1,S1),
mergesort(L2,S2),
merge(S1,S2,S).
split([],[],[]).
split([A],[A],[]).
split([A,B|R],[A|Ra],[B|Rb]) :- split(R,Ra,Rb).
merge(A,[],A).
merge([],B,B).
merge([A|Ra],[B|Rb],[A|M]) :- A =<B, merge(Ra,[B|Rb],M).
merge([A|Ra],[B|Rb],[B|M]) :- A >B, merge([A|Ra],Rb,M).
Lists and Sequences (cont.)
• Predicate op/3
– op(+Precedence, +Type, :Name)
– Precedence: 0 ~ 1200
– Type: xf, yf, xfx, xfy, yfx, fy or fx
• f: position of the function
• y: position for term with precedence lower or equal to the precedence of the function
• x: position for term with precedence strictly lower
• Example
– 1200 xfx --> :-
– 1200 fx :- ?-
– 1000 xfy ,
– 200 fy + - \
– 100 yfx .
Use of op/3
:- op(500,xfx,'is_parent').
a is_parent b. c is_parent g. f is_parent l. j is_parent q.
a is_parent c. c is_parent h. f is_parent m. j is_parent r.
a is_parent d. c is_parent i. h is_parent n. j is_parent s.
b is_parent e. d is_parent j. i is_parent o. m is_parent t.
b is_parent f. e is_parent k. i is_parent p.
:- op(500,xfx,'is_sibling_of').
X is_sibling_of Y :- Z is_parent X,
Z is_parent Y,
X \== Y.
:-op(500,xfx,'is_same_level_as').
X is_same_level_as X .
X is_same_level_as Y :- W is_parent X,
Z is_parent Y,
W is_same_level_as Z.
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_6.html
Original
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html
Map Coloring (v.2)
adjacent(1,2). adjacent(2,1).
adjacent(1,3). adjacent(3,1). [[1,2],[1,3],
adjacent(1,4). adjacent(4,1). [1,4],[1,5],
adjacent(1,5). adjacent(5,1). [2,3],[2,4],
adjacent(2,3). adjacent(3,2). [3,4],[4,5]]
adjacent(2,4). adjacent(4,2).
adjacent(3,4). adjacent(4,3).
adjacent(4,5). adjacent(5,4).
?- color([[1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[3,4],[4,5]],
[red,green,blue,yellow],
Coloring).
Coloring = [[5,red],[4,green],[3,red],[1,blue],[2,yellow]] ; ... /* 48 solutions */
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_9.html
Map Coloring (v.2)
adjacent(X,Y,Map) :- color(Map,Colors,Coloring) :-
member([X,Y],Map) ; member([Y,X],Map). find_regions(Map,[],Regions),
color_all(Regions,Colors,Coloring),
find_regions([],R,R). \+ conflict(Map,Coloring).
find_regions([[X,Y]|S], R, A) :- color_all([R|Rs],Colors,[[R,C]|A]) :-
(member(X,R) -> member(C,Colors),
(member(Y,R) -> find_regions(S,R,A) ; color_all(Rs,Colors,A).
find_regions(S,[Y|R],A)) ; color_all([],_,[]).
(member(Y,R) -> find_regions(S,[X|R],A) ;
find_regions(S,[X,Y|R],A) ) ).
conflict(Map,Coloring) :-
IF member(X,R) member([R1,C],Coloring),
THEN {IF member(Y,R) THEN find_regions(S,R,A) member([R2,C],Coloring),
ELSE find_regions(S,[Y|R],A)} adjacent(R1,R2,Map).
ELSE {IF member(Y,R) THEN find_regions(S,[X|R],A)
ELSE find_regions(S,[X,Y|R],A)} map1([[1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[3,4],[4,5]] ).
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_9.html
4-Queens Problem
• [3, 1, 4, 2].
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html
Map Coloring
adjacent(1,2). adjacent(2,1).
adjacent(1,3). adjacent(3,1). conflict(Coloring) :-
adjacent(1,4). adjacent(4,1). adjacent(X,Y),
adjacent(1,5). adjacent(5,1). color(X,Color,Coloring),
adjacent(2,3). adjacent(3,2). color(Y,Color,Coloring).
adjacent(2,4). adjacent(4,2).
adjacent(3,4). adjacent(4,3). ?- conflict(a).
adjacent(4,5). adjacent(5,4). false.
?- color([[1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[3,4],[4,5]],
[red,green,blue,yellow],
Coloring).
Coloring = [[5,red],[4,green],[3,red],[1,blue],[2,yellow]] ; ... /* 48 solutions */
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_9.html
Map Coloring (v.2)
adjacent(X,Y,Map) :- color(Map,Colors,Coloring) :-
member([X,Y],Map) ; member([Y,X],Map). find_regions(Map,[],Regions),
color_all(Regions,Colors,Coloring),
find_regions([],R,R). \+ conflict(Map,Coloring).
find_regions([[X,Y]|S], R, A) :- color_all([R|Rs],Colors,[[R,C]|A]) :-
(member(X,R) -> member(C,Colors),
(member(Y,R) -> find_regions(S,R,A) ; color_all(Rs,Colors,A).
find_regions(S,[Y|R],A)) ; color_all([],_,[]).
(member(Y,R) -> find_regions(S,[X|R],A) ;
find_regions(S,[X,Y|R],A) ) ).
conflict(Map,Coloring) :-
IF member(X,R) member([R1,C],Coloring),
THEN {IF member(Y,R) THEN find_regions(S,R,A) member([R2,C],Coloring),
ELSE find_regions(S,[Y|R],A)} adjacent(R1,R2,Map).
ELSE {IF member(Y,R) THEN find_regions(S,[X|R],A)
ELSE find_regions(S,[X,Y|R],A)} map1([[1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[3,4],[4,5]] ).
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_9.html
4-Queens Problem
• [3, 1, 4, 2].
• 中正11/23活動報名連結:
https://www.surveycake.com/s/pdoO7
• 帳號註冊
https://aws.amazon.com/tw/education/awseducate/