با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
برای ساختن یک شبکه عصبی که غیرخطیها را یاد میگیرد، با ساختار مدل آشنا زیر شروع کنید: یک مدل خطی به شکل $y' = b + w_1x_1 + w_2x_2 + w_3x_3$.
میتوانیم این معادله را مطابق شکل زیر تجسم کنیم، که در آن $x_1$، $x_2$، و $x_3$ سه گره ورودی ما (به رنگ آبی) و $y'$ گره خروجی ما (به رنگ سبز) هستند.
تمرین 1
در مدل بالا، مقادیر وزن و بایاس به طور تصادفی مقداردهی اولیه شده اند. برای آشنایی با رابط و بررسی مدل خطی، کارهای زیر را انجام دهید. فعلاً میتوانید از منوی کشویی تابع فعالسازی چشمپوشی کنید. بعداً در ماژول در مورد این موضوع بحث خواهیم کرد.
روی دکمه Play (▶️) در بالای شبکه کلیک کنید تا مقدار گره خروجی برای مقادیر ورودی $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
ما یک لایه پنهان حاوی چهار نورون به مدل اضافه کرده ایم.
روی دکمه Play (▶️) بالای شبکه کلیک کنید تا مقدار چهار گره لایه پنهان و گره خروجی برای مقادیر ورودی $x_1 = 1.00$، $x_2 = 2.00$، و $x_3 = 3.00$ محاسبه شود.
سپس مدل را بررسی کنید و از آن برای پاسخ به سوالات زیر استفاده کنید.
مدل اصلی ما در تمرین 1 چهار پارامتر داشت: w 11 , w 21 , w 31 و b. از آنجایی که این مدل دارای یک لایه پنهان است، پارامترهای بیشتری وجود دارد.
12
توجه داشته باشید که تعداد کل پارامترها شامل پارامترهای مورد استفاده برای محاسبه مقادیر گره در لایه پنهان از مقادیر ورودی و پارامترهای مورد استفاده برای محاسبه مقدار خروجی از مقادیر گره در لایه پنهان است.
16
توجه داشته باشید که تعداد کل پارامترها شامل پارامترهای وزن و پارامترهای بایاس می شود.
21
4 پارامتر برای محاسبه هر یک از 4 مقدار گره در لایه پنهان استفاده می شود - 3 وزن (یکی برای هر مقدار ورودی) و یک بایاس - که مجموع آنها به 16 پارامتر می رسد. سپس از 5 پارامتر برای محاسبه مقدار خروجی استفاده می شود: 4 وزن (یکی برای هر گره در لایه پنهان) و یک بایاس. در مجموع این شبکه عصبی دارای 21 پارامتر است.
سعی کنید پارامترهای مدل را تغییر دهید و تأثیر آن را بر روی مقادیر گره لایه پنهان و مقدار خروجی مشاهده کنید (برای مشاهده نحوه محاسبه این مقادیر می توانید پانل محاسبات زیر را بررسی کنید).
آیا این مدل می تواند غیرخطی ها را یاد بگیرد؟
بله
روی هر یک از گره های لایه مخفی و گره خروجی کلیک کنید و محاسبات زیر را مرور کنید. در مورد همه این محاسبات به چه چیزی توجه می کنید؟
خیر
اگر روی هر یک از گره های لایه پنهان کلیک کنید و محاسبات زیر را مرور کنید، خواهید دید که همه آنها خطی هستند (شامل عملیات ضرب و جمع هستند).
اگر سپس روی گره خروجی کلیک کنید و محاسبه زیر را مرور کنید، خواهید دید که این محاسبه نیز خطی است. محاسبات خطی انجام شده بر روی خروجی محاسبات خطی نیز خطی هستند، به این معنی که این مدل نمی تواند غیرخطی ها را یاد بگیرد.
تاریخ آخرین بهروزرسانی 2024-10-31 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-10-31 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Neural networks: Nodes and hidden layers\n\nTo 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----------\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----------------------------\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----------\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)"]]