Presentation is loading. Please wait.

Presentation is loading. Please wait.

ברוכים הבאים! מבוא לקורס ולשפת Python

Similar presentations


Presentation on theme: "ברוכים הבאים! מבוא לקורס ולשפת Python"— Presentation transcript:

1 ברוכים הבאים! מבוא לקורס ולשפת Python
מבוא לבינה מלאכותית (236501) מדעי המחשב, טכניון עומר גייגר חורף AI

2 קצת מנהלות... ברוכים הבאים לקורס! בשם הצוות:
פרופ' שאול מרקוביץ' יום ה' 12:30-14:30 ליאור פרידמן ד' 9:30-10:20 מיטל מסינג ג' 16:30-17:20 עומר גייגר (מתרגל אחראי) ב' 9:30-10:20 נועם רביד תגבורים בפייתון הסמסטר (בניגוד לפעמים קודמות) כל מתרגל(ת) ילמד קבוצת תרגול קבועה לאורך כל הסמסטר כנהוג ברוב הקורסים. דרישות קדם: מבני נתונים, אלגוריתמים. מטלות הקורס: 3 תרגילי חובה המשלבים תכנות בPython ודו"ח יבש. בחינה מסכמת.

3 מטלות הקורס תרגיל 1 – בעיית חיפוש ברשת כבישים
תרגיל 2 – תחרות משחק שני שחקנים תרגיל 3 – ניסוי בתחום למידה הרכב הציון: שב 1 שב 2 שב 3 מבחן 40% + בונוסים 60%

4 AI=sexy! על הקורס... זהו קורס מבוא לתחום המרתק של בינה מלאכותית.
"מבוא" – במהלך הסמסטר נטעם מהתחום, לא נסיים כמומחים. קיימות אפשרויות להמשך העמקה בפקולטה ומחוצה לה. "קורס מתקדם" - נניח ידע ביסודות מדעי המחשב: תכנות, אלגוריתמים, מבני נתונים ומתמטיקה. אופי הקורס יוריסטי בדגש אמפירי תוך שילוב מיומנויות תכנות בתרגילי הבית. מתמטיקה פורמאלית, בעיקר תורת הקבוצות, תופיע לעיתים אך אינה הדגש. תכנות בPython – מעט היום, הרבה בבית!

5 מהי בינה מלאכותית? מבחן טיורינג: מערכות המסוגלות לחקות אדם.
סוכני תוכנה\חומרה אוטונומיים המסוגלים לחוש, לתכנן, להסיק מסקנות, להכליל, ללמוד, להפעיל. The study and design of intelligent agents (Poole et al. ‘98) The science and engineering of making intelligent machines (McCarthy, ‘95) The science of making computers do things that require intelligence when done by humans ( Deduction, reasoning & problem solving Knowledge representation Planning Learning Natural language Motion and manipulation Perception Social intelligence Creativity General intelligence (Wikipedia)

6 מה נלמד בקורס? הגדרת מרחבי מצבים לבעיה
אלגוריתמי חיפוש מיודעים ולא מיודעים במרחבים משחקים - אלגוריתם Minimaxו-ווריאציות שלו ייצוג אילוצים לוגיים וחיפוש פתרון (Constraint Satisfaction Problems) מערכות לומדות (Machine Learning) ואולי נושאים נוספים ...

7 Through examples

8 Python – מקורות מומלצים (ללמידה עצמית)
האתר הרשמי: (מכאן גם מומלץ להוריד את הסביבה – שימו לב! גרסה 2.7.3) המדריך הרשמי: סיכומים שבאתר הקורס - באדיבות ארז כרפס. חומרים נוספים ברשת: stackoverflow, אתרי אוניברסיטאות ואחרים.

9 Python על קצה המזלג Compact code - פיתוח קצר ומימוש מהיר.
High Level - מבני נתונים אבסטרקטיים. Interpreted - קוד מפוענח בזמן ריצה ומתבצע. Dynamic typing - הטיפוס משויך לאובייקט ולא למשתנה. Strongly typed - המרות לא טריוויאליות רק בדרישה מפורשת. Object Oriented - מחלקות, אובייקטים, ירושה וכיו"ב. Platform compatible Virtual Machine,: Win 32/64, Unix, Linux, Mac...

10 Python vs. C/C++ Much Shorter!!! C \ C++ Code Compile Run Python Code
Another option (Interactive shell): 1. Code & Run!

11 Built-in types

12 Basic operators Basic arithmetics: + - * / Modulu: % Div: // Power: **
Boolean bit ops: & (and) | (or) ^ (xor) ~ (neg 2’s comp.) Bit shift: <<, >> Assign and op: +=, **=, ^= etc… Logical: and, or, not Comparison: <, >, <=, >=, == Generally, Operators are overloaded for all reasonable operand types

13 Python Interpreter as a calculator

14 Variables No variable declaration Defined upon assignment
Variable type and value are defined by last value assigned Therefore type may change dynamically (thus “Dynamic Typing”)

15 if, elif, else raw_input() for getting an input string int() casting
Note the ‘:’ in the syntax Indentation matters (no curly brackets) The interpreter waits for code completion with secondary prompt (‘…’) print() and some other functions work without brackets Note the multiple condition 0 <= x <= 9

16 While loop Again note the ‘:’ and indentation
continue & break commands like in C Note the optional ‘while - else’

17 list type Empty list definition using [ ]
Elements may be of any type and different types in same list Basic ops: +, *, append(), extend(), [ndx], len, in, del range( ), range( , ) functions create lists of consecutive ints Slicing for read or write [from : to] , [from : to : jumps] Note the possibility of omitting one or both of the limits (from,to) Note the [::-1] giving the entire list but in reverse order

18 for loop for <variable> in <sequence-type> :
xrange() is similar to range() but lazy, evaluates next value when requested Note the formatted print using %d %s %f similar to C Again note the optional ‘else’

19 functions def <func-name> (<params>): …
return <ret-val> After defined, the function name becomes an object identifier It may be assigned to a variable and has methods like any object

20 dictionary A dictionary is an “assosiative array”, a set of <key>:<val> pairs Each key may be any immutable type Values may be mutable The empty dictionary is { } Functions used here: chr, ord, zip Note the “List comprehension” syntax in the assignment to values (2nd line)

21

22 {i+1:chr(ord('a‘)+i) for i in xrange(5)}
Dict comprehension {i+1:chr(ord('a‘)+i) for i in xrange(5)}

23 classes - Tree inherits object - __init__() is the constructor
- ‘self’ is a convention name for “this” - Members defined by assignment - Default values defined with ‘=‘ (like C++) - NewTreeMain module imports Tree - Notice the check __name__ == ‘__main__’ to avoid runing imported modules

24 טיפים להשתמש בshell להימנע מלולאות list/dict comprehension
להשתמש במילונים לשמור את הקוד בקובץ להשתמש בקיצורים שימושים שמספקת סביבת הפיתוח כמו בcntrl+space בEclipse, alt+p, alt+? בIdle.

25 Practice - Python hands on
טעמנו קצת, מומלץ מאוד לקרוא את המדריך הרשמי של פייתון נושאים חשובים נוספים: Exceptions, Modules & Packages, I\O with Files, variable scope, standard libs, … תרגיל התנסות לא להגשה נמצא באתר אתם מוזמנים לשלוח באימייל למתרגלים: שאלות, הערות והמלצות לפרסום בFAQ (גישת קהילת לומדים) מומלץ בחום לנסות ולהתמודד. הניסיון עשוי לעזור בתרגילים הבאים...


Download ppt "ברוכים הבאים! מבוא לקורס ולשפת Python"

Similar presentations


Ads by Google