الخطوة 5: ضبط المَعلمات الفائقة
تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
كان علينا اختيار عدد من المعلمات الزائدة لتحديد النموذج وتدريبه. واعتمدنا على الحدس والأمثلة واقتراحات أفضل الممارسات. ومع ذلك، قد لا يؤدي اختيارنا الأول لقيم المعلَمة الفائقة إلى تحقيق أفضل النتائج. تمنحنا هذه الطريقة نقطة بداية جيدة للتدريب. تختلف كل مشكلة عن غيرها، وتساعد ضبط هذه المعلَمات الفائقة في تحسين نموذجنا لتمثيل جوانب المشكلة التي تواجهك بشكل أفضل. لنلقِ نظرة على بعض المعلَمات الفائقة التي استخدمناها وما يعنيه ذلك:
عدد الطبقات في النموذج: عدد الطبقات في الشبكة العصبونية هو مؤشر لمدى التعقيد. يجب أن نتوخى الحذر عند اختيار هذه القيمة. وسيسمح عدد كبير جدًا من الطبقات للنموذج بتعلّم الكثير من المعلومات حول بيانات التدريب، ما يتسبب في التجاوز. قلة عدد الطبقات يمكن أن تؤدي إلى الحدّ من قدرة التعلّم الخاصة بالنموذج، ما يؤدي إلى عدم ملاءمتها. بالنسبة إلى مجموعات بيانات تصنيف النصوص، أجرينا تجربة على استخدام MLP واحدة وثلاثين وثلاث طبقات. التي حققت النماذج ذات الطبقات الثلاث أداءً جيدًا، وفي بعض الحالات أفضل من النماذج الثلاث. كذلك، جرّبنا بروتوكول sepCNN مع أربع وستات طبقات، وكان أداء النماذج المكوّنة من أربع طبقات جيدًا.
عدد الوحدات لكل طبقة: يجب أن تتضمن الوحدات الموجودة في الطبقة المعلومات للتحويل الذي تجريه الطبقة. بالنسبة إلى الطبقة الأولى، يعتمد هذا على عدد الميزات. في الطبقات اللاحقة، يعتمد عدد الوحدات على اختيار توسيع التمثيل أو التعاقد عليه من الطبقة السابقة. حاوِل تقليل فقدان المعلومات بين الطبقات. لقد جرّبنا قيم الوحدات في النطاق [8, 16, 32, 64]
، ونجحت وحدات 32/64.
معدّل الانسحاب: تُستخدَم طبقات الخروج في النموذج للتسوية. تحدّد هذه النسبة جزءًا من المدخلات يُستخدم كتدبير وقائي لتجنّب الازدحام الزائد. النطاق المقترَح: 0.2–0.5.
معدّل التعلّم: هذا هو معدّل تغيّر قيمة ترجيح الشبكة العصبونية بين التكرارات. وقد يؤدي معدل التعلّم الكبير إلى حدوث تقلبات كبيرة في الأوزان، وقد لا نتمكّن أبدًا من العثور على القيم المثالية. يُعدّ معدّل التعلّم المنخفض جيدًا، ولكن يتطلّب النموذج مزيدًا من التكرارات للتقارب. من المفيد أن تبدأ على مستوى منخفض، مثلاً من 1 إلى 4. إذا كان التدريب بطيئًا جدًا، ارفع هذه القيمة. إذا لم يكن نموذج التعلُّم متعلّمًا، حاوِل تقليل معدّل التعلّم.
في ما يلي معلّمات زائدة أخرى عدّلناها وفقًا لنموذج sepCNN:
حجم النواة: حجم نافذة الالتفاف. القيم المقترَحة: 3 أو 5.
أبعاد التضمين: عدد الأبعاد التي نريد استخدامها لتمثيل تضمينات الكلمات، أي حجم كل متّجه كلمة. القيم المقترَحة: 50 إلى 300. في تجاربنا، استخدمنا إدراجات GloVe مع 200 بُعد باستخدام طبقة تضمين مدرّبة مسبقًا.
اختبر هذه المعلمات الفائقة وابحث عن الأفضل أداءً. بعد أن اختَرت المعلمات العالية الأداء الأفضل أداءً لحالة الاستخدام، تصبح نموذجك جاهزًا للنشر.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eInitial hyperparameter choices provide a starting point for model training, but further tuning is crucial to optimize performance for specific text classification problems.\u003c/p\u003e\n"],["\u003cp\u003eThe number of layers in a neural network impacts its complexity, with two-layer MLPs and four-layer sepCNNs showing promising results in text classification.\u003c/p\u003e\n"],["\u003cp\u003eKey hyperparameters to adjust include the number of units per layer (32 or 64 performed well), dropout rate (0.2-0.5 recommended), and learning rate (start low and adjust based on training progress).\u003c/p\u003e\n"],["\u003cp\u003eFor sepCNN models, optimizing kernel size (3 or 5) and embedding dimensions (50-300) further enhances performance.\u003c/p\u003e\n"],["\u003cp\u003eExperimenting with different hyperparameter combinations is essential to achieve the best model performance for your specific use case before deployment.\u003c/p\u003e\n"]]],[],null,["We had to choose a number of hyperparameters for defining and training the\nmodel. We relied on intuition, examples and best practice recommendations. Our\nfirst choice of hyperparameter values, however, may not yield the best results.\nIt only gives us a good starting point for training. Every problem is different\nand tuning these hyperparameters will help refine our model to better represent\nthe particularities of the problem at hand. Let's take a look at some of the\nhyperparameters we used and what it means to tune them:\n\n- **Number of layers in the model** : The number of layers in a neural network is\n an indicator of its complexity. We must be careful in choosing this value. Too\n many layers will allow the model to learn too much information about the\n training data, causing overfitting. Too few layers can limit the model's\n learning ability, causing underfitting. For text classification datasets, we\n experimented with one, two, and three-layer MLPs. Models with two layers\n performed well, and in some cases better than three-layer models. Similarly, we\n tried [sepCNN](https://developers.google.com/machine-learning/glossary?utm_source=DevSite&utm_campaign=Text-Class-Guide&utm_medium=referral&utm_content=glossary&utm_term=sepCNN#depthwise-separable-convolutional-neural-network-sepcnn)s\n with four and six layers, and the four-layer models performed well.\n\n- **Number of units per layer** : The units in a layer must hold the information\n for the transformation that a layer performs. For the first layer, this is\n driven by the number of features. In subsequent layers, the number of units\n depends on the choice of expanding or contracting the representation from the\n previous layer. Try to minimize the information loss between layers. We tried\n unit values in the range `[8, 16, 32, 64]`, and 32/64 units worked well.\n\n- **Dropout rate** : Dropout layers are used in the model for\n [regularization](https://developers.google.com/machine-learning/glossary/?utm_source=DevSite&utm_campaign=Text-Class-Guide&utm_medium=referral&utm_content=glossary&utm_term=dropout-regularization#dropout_regularization).\n They define the fraction of input to drop as a precaution for overfitting.\n Recommended range: 0.2--0.5.\n\n- **Learning rate**: This is the rate at which the neural network weights change\n between iterations. A large learning rate may cause large swings in the weights,\n and we may never find their optimal values. A low learning rate is good, but the\n model will take more iterations to converge. It is a good idea to start low, say\n at 1e-4. If the training is very slow, increase this value. If your model is not\n learning, try decreasing learning rate.\n\nThere are couple of additional hyperparameters we tuned that are specific to our\nsepCNN model:\n\n1. **Kernel size**: The size of the convolution window. Recommended values: 3 or\n 5.\n\n2. **Embedding dimensions**: The number of dimensions we want to use to represent\n word embeddings---i.e., the size of each word vector. Recommended values: 50--300.\n In our experiments, we used GloVe embeddings with 200 dimensions with a pre-\n trained embedding layer.\n\nPlay around with these hyperparameters and see what works best. Once you have\nchosen the best-performing hyperparameters for your use case, your model is\nready to be deployed."]]