الشبكات العصبية: تمارين تفاعلية
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
في التمارين التفاعلية أدناه، ستستكشف بشكل أكبر الأعمال الداخلية
والشبكات العصبية. أولًا، سوف نتعرَّف على التغييرات في المَعلَمات والمعلَمات الفائقة
تؤثر في تنبؤات الشبكة. بعد ذلك ستستخدم ما تعلمته لتدريب
الشبكة العصبية لتتناسب مع البيانات غير الخطية.
التمرين 1
تعمل الأداة التالية على إعداد شبكة عصبية بالتهيئة التالية:
- طبقة إدخال تحتوي على 3 خلايا عصبية تحتوي على القيم
0.00
و0.00
و0.00
- طبقة مخفية تحتوي على 4 خلايا عصبية
- طبقة إخراج تحتوي على خلية عصبية واحدة
- تم تطبيق دالة التفعيل ReLU على
جميع عُقد الطبقة المخفية وعقدة الإخراج
راجِع الإعداد الأولي للشبكة (ملاحظة: لا تنقر على ▶️ أو
>| حتى الآن)، ثم أكمِل المهام أسفل الأداة.
المهمة 1
قيم خصائص الإدخال الثلاث لنموذج الشبكة العصبية هي جميعها
0.00
انقر على كل عُقدة في الشبكة للاطلاع على جميع العقد
القيم. قبل النقر على الزر "تشغيل" (▶️)، أجب عن السؤال التالي:
ما نوع قيمة الناتج
أعتقد أنه سيتم إنتاجه: إيجابي أم سلبي أم 0؟
قيمة ناتج موجبة
لقد اخترت إيجابية
قيمة المخرجات. اتّبِع التعليمات أدناه.
لإجراء استنتاج على بيانات الإدخال ومعرفة ما إذا كنت على حق.
قيمة المخرجات السلبية
لقد اخترت سلبية
قيمة المخرجات. اتّبِع التعليمات أدناه.
لإجراء استنتاج على بيانات الإدخال ومعرفة ما إذا كنت على حق.
قيمة الإخراج 0
لقد اخترت الناتج
تساوي 0. اتّبِع التعليمات أدناه.
لإجراء استنتاج على بيانات الإدخال ومعرفة ما إذا كنت على حق.
انقر الآن على الزر "تشغيل" (▶️) فوق الشبكة، وشاهد جميع الطبقات المخفية
وتعبئة قيم عقدة الإخراج. هل كانت إجابتك أعلاه صحيحة؟
انقر هنا للاطّلاع على شرح.
ستختلف القيمة الدقيقة للمخرجات التي تحصل عليها بناءً على مقياس
ويتم تهيئة معلمات التحيز بشكل عشوائي. ومع ذلك، ونظرًا لأن كل خلية عصبية
القيمة 0 في طبقة الإدخال، والأوزان المستخدمة لحساب
فسيتم حذف جميع قيم العقدة ذات الطبقة المخفية. على سبيل المثال،
سيكون حساب عقدة الطبقة المخفية على النحو التالي:
y = ReLU(w11* 0.00 + w21* 0.00 + w31* 0.00 + b)
y = ReLU(b)
إذًا، ستكون قيمة كل عقدة ذات طبقة مخفية مساوية لقيمة ReLU
التحيز (b)، والذي سيكون 0 إذا كانت b سالبة وb نفسها إذا كانت b 0 أو
إيجابية.
بعد ذلك، سيتم احتساب قيمة عقدة الإخراج على النحو التالي:
y = ReLU(w11* x11 + w21* x21
+ 31* ×31 + w41* x41 + b)
المهمة 2
قبل تعديل الشبكة العصبية، أجب عن السؤال التالي:
في حال إضافة طبقة مخفية أخرى
إلى الشبكة العصبية بعد الطبقة المخفية الأولى، وامنح هذه الطبقة الجديدة 3 عُقد، مع الاحتفاظ بجميع
المدخلات والوزن/التحيز متماثلة، أي الأجزاء الأخرى العمليات الحسابية
سيتأثر بذلك؟
جميع العُقد
في الشبكة، باستثناء عُقد الإدخال
لقد اخترت جميع
في الشبكة، باستثناء عُقد الإدخال. اتّبِع
الإرشادات أدناه لتحديث الشبكة العصبية ومعرفة ما إذا كنت
صحيح.
تمثل فقط العقد في
الطبقة المخفية الأولى
لقد اخترت فقط
العُقد في الطبقة المخفية الأولى. اتّبِع التعليمات أدناه.
لتحديث الشبكة العصبية ومعرفة ما إذا كنت على صواب
عقدة الإخراج فقط
لقد اخترت فقط
عقدة ناتج. اتّبِع التعليمات أدناه لتعديل
الشبكة العصبية ومعرفة ما إذا كنت صحيحًا.
عدّل الآن الشبكة العصبية لإضافة طبقة جديدة مخفية تحتوي على 3 عُقد على النحو التالي:
- انقر على الزر + على يمين النص طبقة واحدة مخفية لإضافة طبقة جديدة.
طبقة مخفية قبل طبقة الإخراج.
- انقر على الزر + فوق الطبقة المخفية الجديدة مرّتين لإضافة عقدتَين أخريَين.
إلى الطبقة.
هل كانت إجابتك أعلاه صحيحة؟
انقر هنا للاطّلاع على شرح.
تتغير عقدة الإخراج فقط. لأن الاستنتاج الخاص بهذه الشبكة العصبية
هو "feed-forward" (تقدم العمليات الحسابية من البداية إلى النهاية)، فإن إضافة
أي طبقة جديدة على الشبكة إلا في العُقد بعد
وليس تلك التي تسبقها.
المهمة 3
انقر على العقدة الثانية (من أعلى الصفحة) في الطبقة المخفية الأولى من الشبكة.
الرسم البياني. قبل إجراء أي تغييرات على تهيئة الشبكة، أجب على
السؤال التالي:
إذا غيّرت قيمة
الوزن w12 (يتم عرضه أسفل أول عقدة إدخال، x1)،
العُقد الأخرى العمليات الحسابية قد تتأثر ببعض المدخلات
القيم؟
لا ينطبق
لقد اخترت بدون
. اتبع الإرشادات أدناه لتحديث الشبكة العصبية
لترى ما إذا كنت صحيحًا.
العقدة الثانية في
الطبقة الأولى المخفية وجميع عُقد الطبقة المخفية الثانية
عقدة ناتج.
لقد اخترت الثاني
في الطبقة الأولى المخفية، و وتضم جميع العُقد في الطبقة المخفية الثانية،
وعقدة الإخراج. اتّبِع التعليمات أدناه.
لتحديث الشبكة العصبية ومعرفة ما إذا كنت على صواب
يجب أن تكون جميع العقد في
الطبقة الأولى المخفية والطبقة المخفية الثانية وطبقة الإخراج.
لقد اخترت جميع
في الطبقة الأولى المخفية والطبقة الثانية المخفية
طبقة الإخراج. اتّبِع التعليمات أدناه.
لتحديث الشبكة العصبية ومعرفة ما إذا كنت على صواب
انقر الآن على حقل النص للوزن w12 (المعروض أسفل
عقدة الإدخال الأولى، x1)، غيّر قيمتها إلى 5.00
، واضغط على Enter.
تتبُّع التعديلات على الرسم البياني.
هل كانت إجابتك صحيحة؟ توخ الحذر عند التحقق من إجابتك: إذا كانت هناك عقدة
لا تتغير، فهل هذا يعني أن العملية الحسابية الأساسية لم تتغير؟
انقر هنا للاطّلاع على شرح.
العقدة الوحيدة المتأثرة في الطبقة الأولى المخفية هي العقدة الثانية (
الذي نقرت عليه). العمليات الحسابية للقيمة للعُقد الأخرى في أول
الطبقة المخفية لا تحتوي على w12 كمعلمة، لذا لا
المتأثرة. تتأثر جميع العقد في الطبقة المخفية الثانية، حيث إن
العمليات الحسابية على قيمة العقدة الثانية في
طبقة مخفية. وبالمثل، تتأثر قيمة عقدة الإخراج بسبب
العمليات الحسابية على قيم العقد في الطبقة المخفية الثانية.
هل تعتقد أن الإجابة "لا شيء" لأنه لا يوجد أي من قيم العقدة في
تغيرت الشبكة عندما قمت بتغيير قيمة الوزن؟ لاحظ أنه
قد تتغير العملية الحسابية للعقدة بدون تغيير قيمة العقدة
(مثال: وتُنتج كل من ReLU(0) وReLU(–5) ناتج 0).
لا تضع افتراضات حول كيفية تأثر الشبكة فقط
بالنظر إلى قيم العقدة؛ تأكد من مراجعة العمليات الحسابية أيضًا.
التمرين 2
في التمارين المتقاطعة الميزات
في وحدة البيانات الفئوية،
قمت ببناء الخصائص يدويًا لملاءمة البيانات غير الخطية.
والآن، سترى ما إذا كان بإمكانك إنشاء شبكة عصبية يمكنها التعلم
كيفية ملاءمة البيانات غير الخطية أثناء التدريب.
مهمتك: تكوين شبكة عصبية يمكنها فصل النقاط البرتقالية عن
النقاط الزرقاء في الرسم التخطيطي أدناه، مما أدى إلى خسارة أقل من 0.2 في كلتيهما
بيانات التطبيق والاختبار.
Instructions:
في التطبيق المصغّر التفاعلي أدناه:
- عدِّل مُدخلات الشبكة العصبونية الفائقة من خلال تجربة بعض
بإعدادات الضبط التالية:
- يمكنك إضافة طبقات مخفية أو إزالتها بالنقر على الزرّين + و- للانتقال إلى
على يسار عنوان الفئات المخفية في الرسم التخطيطي للشبكة.
- إضافة أو إزالة الخلايا العصبية من طبقة مخفية بالنقر على + و-
أعلى عمود ذي طبقة مخفية.
- يمكنك تغيير معدّل التعلّم من خلال اختيار قيمة جديدة من معدّل التعلّم.
المنسدلة أعلى المخطط.
- قم بتغيير دالة التفعيل عن طريق اختيار قيمة جديدة من
القائمة المنسدلة التفعيل أعلى المخطّط البياني.
- انقر على الزر "تشغيل" (▶️) أعلى المخطّط البياني لتدريب الشبكة العصبونية.
نموذج باستخدام المعاملات المحددة.
- لاحظ تصور النموذج الذي يناسب البيانات كتدريب
التقدم، بالإضافة إلى
اختبار الخسارة
قيم خسارة التدريب في
قسم الإخراج.
- فإذا لم يحقق النموذج خسارة أقل من 0.2 في بيانات الاختبار والتدريب،
النقر على "إعادة الضبط"، وتكرار الخطوات من 1 إلى 3 مع مجموعة مختلفة من الإعدادات
الإعدادات. كرر هذه العملية حتى تحقق النتائج المفضلة.
انقر هنا للاطّلاع على الحلّ
لقد تمكنا من تحقيق كل من خسارة الاختبار والتدريب أقل من 0.2 من خلال:
- إضافة طبقة مخفية تحتوي على 3 خلايا عصبية.
- اختيار معدل التعلم 0.01.
- اختيار وظيفة تفعيل ReLU
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-08-16 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-08-16 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Neural networks: Interactive exercises\n\nIn the interactive exercises below, you'll further explore the inner workings of\nneural networks. First, you'll see how parameter and hyperparameter changes\naffect the network's predictions. Then you'll use what you've learned to train a\nneural network to fit nonlinear data.\n\nExercise 1\n----------\n\nThe following widget sets up a neural network with the following configuration:\n\n- Input layer with 3 neurons containing the values `0.00`, `0.00`, and `0.00`\n- Hidden layer with 4 neurons\n- Output layer with 1 neuron\n- [**ReLU**](/machine-learning/glossary#ReLU) activation function applied to all hidden layer nodes and the output node\n\nReview the initial setup of the network (note: **do not** click the **▶️** or\n**\\\u003e\\|** buttons yet), and then complete the tasks below the widget.\n\n### Task 1\n\nThe values for the three input features to the neural network model are all\n`0.00`. Click each of the nodes in the network to see all the initialized\nvalues. Before hitting the Play (**▶️**) button, answer this question: \nWhat kind of output value do you think will be produced: positive, negative, or 0? \nPositive output value \nYou chose **positive\noutput value**. Follow the instructions below to perform inference on the input data and see if you're right. \nNegative output value \nYou chose **negative\noutput value**. Follow the instructions below to perform inference on the input data and see if you're right. \nOutput value of 0 \nYou chose **output\nvalue of 0**. Follow the instructions below to perform inference on the input data and see if you're right.\n\nNow click the Play (▶️) button above the network, and watch all the hidden-layer\nand output node values populate. Was your answer above correct? \n**Click here for an explanation**\n\nThe exact output value you get will vary based on how the weight\nand bias parameters are randomly initialized. However, since each neuron\nin the input layer has a value of 0, the weights used to calculate the\nhidden-layer node values will all be zeroed out. For example, the first\nhidden layer node calculation will be:\n\ny = ReLU(w~11~\\* 0.00 + w~21~\\* 0.00 + w~31~\\* 0.00 + b)\n\ny = ReLU(b)\n\nSo each hidden-layer node's value will be equal to the ReLU value of the\nbias (b), which will be 0 if b is negative and b itself if b is 0 or\npositive.\n\nThe value of the output node will then be calculated as follows:\n\ny = ReLU(w~11~\\* x~11~ + w~21~\\* x~21~\n+ w~31~\\* x~31~ + w~41~\\* x~41~ + b)\n\n### Task 2\n\nBefore modifying the neural network, answer the following question: \nIf you add another hidden layer to the neural network after the first hidden layer, and give this new layer 3 nodes, keeping all input and weight/bias parameters the same, which other nodes' calculations will be affected? \nAll the nodes in the network, except the input nodes \nYou chose **all the\nnodes in the network, except the input nodes**. Follow the instructions below to update the neural network and see if you're correct. \nJust the nodes in the first hidden layer \nYou chose **just the\nnodes in the first hidden layer**. Follow the instructions below to update the neural network and see if you're correct. \nJust the output node \nYou chose **just the\noutput node**. Follow the instructions below to update the neural network and see if you're correct.\n\nNow modify the neural network to add a new hidden layer with 3 nodes as follows:\n\n1. Click the **+** button to the left of the text **1 hidden layer** to add a new hidden layer before the output layer.\n2. Click the **+** button above the new hidden layer twice to add 2 more nodes to the layer.\n\nWas your answer above correct? \n**Click here for an explanation**\n\nOnly the output node changes. Because inference for this neural network\nis \"feed-forward\" (calculations progress from start to finish), the addition\nof a new layer to the network will only affect nodes *after* the new\nlayer, not those that precede it.\n\n### Task 3\n\nClick the second node (from the top) in the first hidden layer of the network\ngraph. Before making any changes to the network configuration, answer the\nfollowing question: \nIf you change the value of the weight w~12~ (displayed below the first input node, x~1~), which other nodes' calculations *could* be affected for some input values? \nNone \nYou chose **none**. Follow the instructions below to update the neural network and see if you're correct. \nThe second node in the first hidden layer, all the nodes in the second hidden layer, and the output node. \nYou chose **the second\nnode in the first hidden layer, all the nodes in the second hidden layer,\nand the output node**. Follow the instructions below to update the neural network and see if you're correct. \nAll the nodes in the first hidden layer, the second hidden layer, and the output layer. \nYou chose **all the\nnodes in the first hidden layer, the second hidden layer, and the\noutput layer**. Follow the instructions below to update the neural network and see if you're correct.\n\nNow, click in the text field for the weight w~12~ (displayed below the\nfirst input node, x~1~), change its value to `5.00`, and hit Enter.\nObserve the updates to the graph.\n\nWas your answer correct? Be careful when verifying your answer: if a node\nvalue doesn't change, does that mean the underlying calculation didn't change? \n**Click here for an explanation**\n\nThe only node affected in the first hidden layer is the second node (the\none you clicked). The value calculations for the other nodes in the first\nhidden layer do not contain w~12~ as a parameter, so they are not\naffected. All the nodes in the second hidden layer are affected, as their\ncalculations depend on the value of the second node in the first\nhidden layer. Similarly, the output node value is affected because its\ncalculations depend on the values of the nodes in the second hidden layer.\n\nDid you think the answer was \"none\" because none of the node values in the\nnetwork changed when you changed the weight value? Note that an underlying\ncalculation for a node may change without changing the node's value\n(e.g., ReLU(0) and ReLU(--5) both produce an output of 0).\nDon't make assumptions about how the network was affected just by\nlooking at the node values; make sure to review the calculations as well.\n\nExercise 2\n----------\n\nIn the [Feature cross exercises](/machine-learning/crash-course/categorical-data/feature-cross-exercises)\nin the [Categorical data module](/machine-learning/crash-course/categorical-data),\nyou manually constructed feature crosses to fit nonlinear data.\nNow, you'll see if you can build a neural network that can automatically learn\nhow to fit nonlinear data during training.\n\n**Your task:** configure a neural network that can separate the orange dots from\nthe blue dots in the diagram below, achieving a loss of less than 0.2 on both\nthe training and test data.\n\n**Instructions:**\n\nIn the interactive widget below:\n\n1. Modify the neural network hyperparameters by experimenting with some of the following config settings:\n - Add or remove hidden layers by clicking the **+** and **-** buttons to the left of the **HIDDEN LAYERS** heading in the network diagram.\n - Add or remove neurons from a hidden layer by clicking the **+** and **-** buttons above a hidden-layer column.\n - Change the learning rate by choosing a new value from the **Learning rate** drop-down above the diagram.\n - Change the activation function by choosing a new value from the **Activation** drop-down above the diagram.\n2. Click the Play (▶️) button above the diagram to train the neural network model using the specified parameters.\n3. Observe the visualization of the model fitting the data as training progresses, as well as the [**Test loss**](/machine-learning/glossary#test-loss) and [**Training loss**](/machine-learning/glossary#training-loss) values in the **Output** section.\n4. If the model does not achieve loss below 0.2 on the test and training data, click reset, and repeat steps 1--3 with a different set of configuration settings. Repeat this process until you achieve the preferred results.\n\n**Click here for our solution**\n\nWe were able to achieve both test and training loss below 0.2 by:\n\n- Adding 1 hidden layer containing 3 neurons.\n- Choosing a learning rate of 0.01.\n- Choosing an activation function of ReLU. \n| **Key terms:**\n|\n| - [Test loss](/machine-learning/glossary#test-loss)\n- [Training loss](/machine-learning/glossary#training-loss) \n[Help Center](https://support.google.com/machinelearningeducation)"]]