1 / 25

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

ברוכים הבאים! תרגול מבוא לקורס ולשפת Python. מבוא לבינה מלאכותית (236501) מדעי המחשב, טכניון עומר גייגר, ירון קסנר חורף 2013-14. AI. קצת מנהלות. ברוכים הבאים לקורס! בשם הצוות: פרופ' שאול מרקוביץ' - מרצה הרצאה: ד' 14:30-16:30 ירון קסנר – מתרגל תרגולים: ד' 16:30-17:20

Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. מטלות הקורס • תרגיל 1 – בעיית חיפוש ברשת כבישים • תרגיל 2 – תחרות משחק שני שחקנים • תרגיל 3 – ניסוי בתחום למידה • הרכב הציון: מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

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

  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 (http://www.alanturing.net) Deduction, reasoning & problem solving Knowledge representation Planning Learning Natural language Motion and manipulation Perception Social intelligence Creativity General intelligence (Wikipedia) מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  6. מה נלמד בקורס? • הגדרת מרחבי מצבים לבעיה • אלגוריתמי חיפוש מיודעים ולא מיודעים במרחבים • משחקים - אלגוריתם Minimaxווריאציות • ייצוג אילוצים לוגיים וחיפוש פתרון • מערכות לומדות • מבחנים סטטיסטיים וכלים למחקר אמפירי • ואולי נושאים נוספים ... מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  7. Through examples

  8. Python – מקורות מומלצים(ללמידה עצמית) • האתר הרשמי: http://python.org/ (מכאן גם מומלץ להוריד את הסביבה – שימו לב! גרסה 2.7.3) • המדריך הרשמי: http://docs.python.org/2/tutorial/ • סיכומים שבאתר הקורס - באדיבות ארז כרפס. • חומרים נוספים ברשת: stackoverflow, אתרי אוניברסיטאות ואחרים. מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

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

  10. Python vs. C/C++ Much Shorter!!! C \ C++ Code Compile Run Python Code Run Another option (Interactive shell): 1. Code & Run! מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  11. Built-in types מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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 מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  13. Python Interpreter as a calculator מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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”) מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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 מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  16. While loop • Again note the ‘:’ and indentation • continue & break commands like in C • Note the optional ‘while - else’ מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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’ מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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 מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  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) מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

  21. 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 מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

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

  23. Practice - Python hands on • טעמנו קצת, מומלץ מאוד לקרוא את המדריך הרשמי של פייתוןhttp://docs.python.org/2/tutorial/ • נושאים חשובים נוספים: Exceptions, Modules & Packages, I\O with Files, variable scope, standard libs, … • תרגיל התנסות לא להגשה נמצא באתר • אתם מוזמנים לשלוח באימייל לליאור, עומר, או ירון: • שאלות, הערות והמלצות לפרסום בFAQ(גישת קהילת לומדים) • מומלץ בחום לנסות ולהתמודד. הניסיון עשוי לעזור בתרגילים הבאים... מבוא לבינה מלאכותית (236501) מדעי המחשב- טכניון. עומר גייגר, ירון קסנר חורף 2013-14

More Related