קל לארגן דפים בעזרת אוספים אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כדי ליצור רשת נוירונים שלומד לינאריות, מתחיל במבנה המוכר הבא של המודל: מודל לינארי של הטופס $y' = b + w_1x_1 + w_2x_2 + w_3x_3$
ניתן להמחיש את המשוואה הזו כפי שמוצג בהמשך, כאשר $x_1$, $x_2$ ו-$x_3$ הם שלושת צומתי הקלט (בכחול), ו-$y'$ הוא צומת הפלט שלנו (בירוק).
תרגיל 1
במודל שלמעלה, המשקל וגם ערכי הטיות הוגדרו באופן אקראי אותחל. מבצעים את המשימות הבאות כדי להכיר את ולחקור את המודל הלינארי. אפשר בינתיים מתעלמים מהתפריט הנפתח Activate Function (פונקציית ההפעלה). נדון בזה בהמשך במודול.
לוחצים על לחצן ההפעלה ({5}️) מעל הרשת כדי לחשב את הערך של את צומת הפלט עבור ערכי הקלט $x_1 = 1.00$, $x_2 = 2.00$, ו x_3$ = 3.00$
לוחצים על הצומת השני ב שכבת הקלט ומגדילים את הערך מ-2.00 ל-2.50. חשוב לשים לב שהערך של צומת הפלט משתנה. בחירת הפלט צמתים (בירוק) ולבדוק את החלונית חישובים כדי לראות איך הפלט חושב.
לוחצים על צומת הפלט (בירוק) כדי לראות את המשקל ($w_1$, $w_2$, $w_3$) הטיה ($b$). הקטנת ערך המשקל עבור $w_3$ (שוב, צריך לשים לב שהערך של צומת הפלט והחישובים הבאים) השתנו). לאחר מכן, מגדילים את ערך ההטיות. בדיקת האופן שבו השינויים האלה השפיעו על הפלט של המודל.
הוספת שכבות לרשת
שים לב שכאשר אתה משנה את ערכי המשקל וההטיה של הרשת תרגיל 1 שלא שינה את החישוב המתמטי הכולל בין קלט לפלט. המודל שלנו הוא עדיין מודל לינארי.
אבל מה אם נוסיף עוד שכבה לרשת, בין שכבת הקלט ואת שכבת הפלט? במינוח של רשת נוירונים, שכבות נוספות בין ששכבת הקלט ושכבת הפלט נקראים שכבות מוסתרות והצמתים בשכבות האלה נקראים נוירונים.
הערך של כל נוירון בשכבה הסמויה מחושב באותו אופן כמו הפלט של מודל ליניארי: לוקחים את סכום המכפלה של כל אחד מהקלט (הנוירונים בשכבת הרשת הקודמת) ופרמטר משקל ייחודי, וגם ההטיה. באותו האופן, הנוירונים בשכבה הבאה (כאן, שכבת הפלט) מחושבים באמצעות ערכי הנוירונים של השכבה הסמויה כקלט.
השכבה המוסתרת החדשה הזו מאפשרת למודל לשלב מחדש את נתוני הקלט באמצעות קבוצת פרמטרים חדשה לגמרי. האם זה יכול לעזור למודל שלנו ללמוד על קשרים לא ליניאריים?
תרגיל 2
הוספנו למודל שכבה נסתרת שמכילה ארבעה נוירונים.
יש ללחוץ על לחצן ההפעלה (Back️) מעל הרשת כדי לחשב את הערך של את ארבעת הצמתים של השכבה הנסתרת ואת צומת הפלט עבור ערכי הקלט $x_1 = 1.00$, $x_2 = 2.00$ ו-$x_3 = 3.00$.
לאחר מכן, חוקרים את המודל ונעזרים בו כדי לענות על השאלות הבאות.
כמה פרמטרים (משקל והטיות) עושה שימוש נוירונים יש מודל רשת?
4
המודל המקורי בתרגיל 1 כלל ארבעה פרמטרים: w11, w21, w31 ו-B. כי המודל הזה מכיל יש יותר פרמטרים.
12
שימו לב שהמספר הכולל של הפרמטרים כולל את שני הפרמטרים משמש לחישוב ערכי הצומת בשכבה הסמויה ערכי הקלט, והפרמטרים שמשמשים לחישוב ערך הפלט מערכי הצמתים בשכבה המוסתרת.
16
שימו לב שהמספר הכולל של הפרמטרים כולל גם את המשקל ואת הפרמטרים של ההטיה.
21
4 פרמטרים משמשים לחישוב כל אחד מ-4 ערכי הצמתים של את השכבה הסמויה - שלושה משקולות (אחד לכל ערך קלט) הטיה – מסתכמת ל-16 פרמטרים. לאחר מכן יש 5 פרמטרים כדי לחשב את ערך הפלט: 4 משקלים (אחת לכל צומת והטיה. בסך הכול, ברשת הנוירונים הזו יש 2 .
לנסות לשנות את הפרמטרים של המודל ולצפות בהשפעה בשכבה נסתרת של הצומת ואת ערך הפלט (אפשר לבדוק חלונית החישובים שלמטה מראה את האופן שבו הערכים האלה מחושב).
האם המודל הזה יכול ללמוד על אי ליניאריות?
כן
לוחצים על כל אחד מהצמתים בשכבה הנסתרת ובצומת הפלט ועיינו בחישובים למטה. במה הבחנתם את כל החישובים האלה?
לא
אם תלחצו על כל אחד מהצמתים בשכבה הנסתרת ותבדקו החישובים הבאים יראו שכולם ליניאריים (מרכיבות פעולות כפל וחיבור).
אם לאחר מכן לוחצים על צומת הפלט ובודקים את החישוב אפשר לראות שהחישוב הזה הוא גם לינארי. לינארי על הפלט של חישובים ליניאריים המבוצעים גם לינארי, כלומר המודל הזה לא יכול ללמוד מערכים לא ליניאריים.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2024-08-16 (שעון UTC)."],[],[],null,["To build a [**neural network**](/machine-learning/glossary#neural_network)\nthat learns [**nonlinearities**](/machine-learning/glossary#nonlinear),\nbegin with the following familiar model structure: a\n[**linear model**](/machine-learning/glossary#linear-model) of the form\n$y' = b + w_1x_1 + w_2x_2 + w_3x_3$.\n\nWe can visualize this equation as shown below, where $x_1$,\n$x_2$, and $x_3$ are our three input nodes (in blue), and $y'$ is our output node\n(in green).\n\nExercise 1\n\nIn the model above, the [**weight**](/machine-learning/glossary#weight) and\n[**bias**](/machine-learning/glossary#bias) values have been randomly\ninitialized. Perform the following tasks to familiarize yourself with the\ninterface and explore the linear model. You can\nignore the *Activation Function* dropdown for now; we'll discuss this\ntopic later on in the module.\n\n1. Click the Play (▶️) button above the network to calculate the value of\n the output node for the input values $x_1 = 1.00$, $x_2 = 2.00$, and\n $x_3 = 3.00$.\n\n2. Click the second node in the\n [**input layer**](/machine-learning/glossary#input-layer), and increase\n the value from 2.00\n to 2.50. Note that the value of the output node changes. Select the output\n nodes (in green) and review the *Calculations* panel to see how the output\n value was calculated.\n\n | **Notes about calculations:**\n | - Values displayed are rounded to the hundredths place.\n | - The `Linear()` function simply returns the value it is passed.\n3. Click the output node (in green) to see the weight ($w_1$, $w_2$, $w_3$) and\n bias ($b$) parameter values. Decrease the weight value for\n $w_3$ (again, note that the value of the output node and the calculations below\n have changed). Then, increase the bias value. Review how these changes\n have affected the model output.\n\nAdding layers to the network\n\nNote that when you adjusted the weight and bias values of the network in\n[Exercise 1](#exercise_1), that didn't change the overall mathematical\nrelationship between input and output. Our model is still a linear model.\n\nBut what if we add another layer to the network, in between the input layer\nand the output layer? In neural network terminology, additional layers between\nthe input layer and the output layer are called\n[**hidden layers**](/machine-learning/glossary#hidden_layer), and the nodes\nin these layers are called\n[**neurons**](/machine-learning/glossary#neuron).\n\nThe value of each neuron in the hidden layer is calculated the same way as the\noutput of a linear model: take the sum of the product of each of its inputs\n(the neurons in the previous network layer) and a unique weight parameter,\nplus the bias. Similarly, the neurons in the next layer (here, the output layer)\nare calculated using the hidden layer's neuron values as inputs.\n\nThis new hidden layer allows our model to recombine the input data using another\nset of parameters. Can this help our model learn nonlinear relationships?\n\nExercise 2\n\nWe've added a hidden layer containing four neurons to the model.\n\nClick the Play (▶️) button above the network to calculate the value of\nthe four hidden-layer nodes and the output node for the input values\n$x_1 = 1.00$, $x_2 = 2.00$, and $x_3 = 3.00$.\n\nThen explore the model, and use it to answer the following questions. \nHow many [**parameters**](/machine-learning/glossary#parameter) (weights and biases) does this neural network model have? \n4 \nOur original model in [Exercise 1](#exercise-1) had four parameters: w~11~, w~21~, w~31~, and b. Because this model contains a hidden layer, there are more parameters. \n12 \nNote that the total number of parameters includes both the parameters used to calculate the node values in the hidden layer from the input values, and the parameters used to calculate the output value from the node values in the hidden layer. \n16 \nNote that the total number of parameters includes both the weight parameters and the bias parameters. \n21 \nThere are 4 parameters used to calculate each of the 4 node values in the hidden layer---3 weights (one for each input value) and a bias---which sums to 16 parameters. Then there are 5 parameters used to calculate the output value: 4 weights (one for each node in the hidden layer) and a bias. In total, this neural network has 21 parameters. \nTry modifying the model parameters, and observe the effect on the\nhidden-layer node values and the output value (you can review the\nCalculations panel below to see how these values were\ncalculated).\n\nCan this model learn nonlinearities? \nYes \nClick on each of the nodes in the hidden layer and the output node, and review the calculations below. What do you notice about all these calculations? \nNo \nIf you click on each of the nodes in the hidden layer and review\nthe calculations below, you'll see that all of them are linear\n(comprising multiplication and addition operations).\n\nIf you then click on the output node and review the calculation\nbelow, you'll see that this calculation is also linear. Linear\ncalculations performed on the output of linear calculations are\nalso linear, which means this model cannot learn nonlinearities.\n| **Key terms:**\n|\n| - [Bias](/machine-learning/glossary#bias)\n| - [Hidden layer](/machine-learning/glossary#hidden_layer)\n| - [Input layer](/machine-learning/glossary#input-layer)\n| - [Linear model](/machine-learning/glossary#linear-model)\n| - [Model](/machine-learning/glossary#model)\n| - [Neural network](/machine-learning/glossary#neural_network)\n| - [Neuron](/machine-learning/glossary#neuron)\n| - [Nonlinear](/machine-learning/glossary#nonlinear)\n| - [Parameter](/machine-learning/glossary#parameter)\n- [Weight](/machine-learning/glossary#weight) \n[Help Center](https://support.google.com/machinelearningeducation)"]]