1 / 25

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

ברוכים הבאים! מבוא לקורס ולשפת Python. מבוא לבינה מלאכותית (236501) מדעי המחשב, טכניון חורף 2015-16. AI. קצת מנהלות. ברוכים הבאים לקורס! דרישות קדם: מבני נתונים, אלגוריתמים. מטלות הקורס: 3 תרגילי חובה המשלבים תכנות ב Python ודו"ח יבש. בחינה מסכמת . הרכב הציון:. מטלות הקורס.

apuckett
Télécharger la présentation

ברוכים הבאים! מבוא לקורס ולשפת 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) מדעי המחשב, טכניון חורף 2015-16 AI

  2. קצת מנהלות... ברוכים הבאים לקורס! • דרישות קדם: מבני נתונים, אלגוריתמים. • מטלות הקורס: • 3 תרגילי חובה המשלבים תכנות בPython ודו"ח יבש. • בחינה מסכמת. • הרכב הציון:

  3. מטלות הקורס • תרגיל 1 – בעיית חיפוש ברשת כבישים • תרגיל 2 – תחרות משחק שני שחקנים • תרגיל 3 – ניסוי בתחום הלמידה

  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 (http://www.alanturing.net) 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 – מקורות מומלצים(ללמידה עצמית) • האתר הרשמי: http://python.org/ (מכאן גם מומלץ להוריד את הסביבה – שימו לב! גרסה 3.4) • המדריך הרשמי: https://docs.python.org/3.4/tutorial/ • חומרים נוספים ברשת: stackoverflow, אתרי אוניברסיטאות ואחרים.

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

  10. Python vs. C/C++ Much Shorter!!! C \ C++ Code Compile Run Python Code Run 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 • 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 (‘…’) • 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( ) creates immutable sequences of ints • range() is lazy, evaluates next value when requested • 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> : • Note the formatted print using %d %s %f similar to C • There are also other ways to print variables • 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 • A function can return more than one type of value (not recommended) • Can also return multiple values

  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. Dict comprehension {i+1:chr(ord('a‘)+i) for i in range(5)}

  22. 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

  23. טיפים • מומלץ לעבוד עם IDE כמו Eclipse אוPycharm. • לבדיקות קצרות - השתמשו בshell. • השתמשו בlist/dict comprehension- לצמצום הקוד. • נצלו את מבני הנתונים של פייתון, במיוחד dictionaries. • היעזרו ב-python manual המגיע עם ההתקנה של פייתון.

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

More Related