पांचवां चरण: हाइपरपैरामीटर को ट्यून करना
संग्रह की मदद से व्यवस्थित रहें अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
हमें मॉडल को तय करने और उसकी ट्रेनिंग के लिए कई हाइपरपैरामीटर चुनने थे. हमने सुझाव, उदाहरण, और सबसे सही तरीकों के सुझावों पर भरोसा किया. हालांकि, हाइपरपैरामीटर वैल्यू के लिए हमारा पहला विकल्प, सबसे अच्छे नतीजे नहीं दे सकता. इससे हमें ट्रेनिंग देने के लिए अच्छी शुरुआत मिलती है. हर समस्या अलग होती है और इन हाइपरपैरामीटर को ट्यून करने से, हमारे मॉडल को बेहतर बनाने में मदद मिलती है. इसकी मदद से, समस्या की खासियत को बेहतर तरीके से दिखाया जा सकता है. आइए, इस्तेमाल किए गए कुछ हाइपरपैरामीटर के बारे में जानें. साथ ही, यह भी जानें कि उन्हें लागू करने का क्या मतलब है:
मॉडल में लेयर की संख्या: न्यूरल नेटवर्क में लेयर की संख्या, इसकी जटिलता का संकेत होती है. इस वैल्यू को चुनने में सावधानी बरतें. बहुत सारी लेयर की मदद से, मॉडल ट्रेनिंग के डेटा के बारे में बहुत ज़्यादा जानकारी पा सकता है. इस वजह से, मॉडल को ज़रूरत से ज़्यादा फ़िट हो सकता है. बहुत कम लेयर की वजह से, मॉडल की लर्निंग की क्षमता कम हो सकती है. इस वजह से, फ़िटिंग कम हो जाती है. टेक्स्ट क्लासिफ़िकेशन डेटासेट के लिए, हमने एक, दो, और तीन लेयर वाले एमएलपी के साथ प्रयोग किया. दो लेयर वाले मॉडल अच्छा परफ़ॉर्म करते हैं. कुछ मामलों में ये तीन लेयर वाले मॉडल से बेहतर होते हैं. इसी तरह, हमने चार और छह लेयर वाले 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 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","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 (UTC) को अपडेट किया गया."],[[["\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."]]