5단계: 초매개변수 조정
컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
모델을 정의하고 학습시키기 위해 초매개변수를 여러 개 선택해야 했습니다. 우리는 직관, 예시, 권장사항을 참고했습니다. 그러나 초매개변수 값을 먼저 선택하면 최상의 결과가 나오지 않을 수 있습니다. 단지 좋은 출발점일 뿐입니다. 모든 문제는 다르고 이러한 초매개변수를 조정하면 모델을 구체화하여 문제의 특이성을 더 잘 나타낼 수 있습니다. 사용된 초매개변수 몇 가지와 이러한 매개변수를 조정하는 것이 어떤 의미인지 알아보겠습니다.
모델의 레이어 수: 신경망의 레이어 수는 복잡도를 나타내는 지표입니다. 이 값은 신중하게 선택해야 합니다. 레이어가 너무 많으면 모델이 학습 데이터에 대해 너무 많은 정보를 학습할 수 있으므로 과적합이 발생할 수 있습니다. 레이어가 너무 적으면 모델의 학습 기능이 제한되어 과소적합을 유발할 수 있습니다. 텍스트 분류 데이터 세트의 경우 1~2개의 레이어로 구성된 MLP를 실험했습니다. 2개 레이어로 이루어진 모델은 성능이 우수하며, 경우에 따라 3레이어 모델보다 더 나은 성능을 보입니다. 마찬가지로 4개 및 6개 레이어로 sepCNN을 시도했으며 4개 레이어의 모델은 좋은 성능을 보였습니다.
레이어당 단위 수: 레이어의 단위에는 레이어에서 실행되는 변환에 대한 정보가 포함되어 있어야 합니다. 첫 번째 레이어의 경우 특성 수에 따라 달라집니다. 후속 레이어에서 단위 수는 이전 레이어의 표현 확장 또는 축소 선택에 따라 달라집니다. 레이어 간 정보 손실을 최소화합니다. [8, 16, 32, 64]
범위에서 단위 값을 시도했으며 32/64 단위는 잘 작동했습니다.
드롭아웃 비율: 드롭아웃 레이어는 정규화를 위해 모델에서 사용됩니다. 과적합을 방지하기 위한 드롭으로 입력 비율을 정의합니다. 권장되는 범위는 0.2~0.5입니다.
학습률: 반복 사이에 신경망 가중치가 변경되는 비율입니다. 학습률이 높다면 가중치가 크게 변동될 수 있으며 최적 값이 발견되지 않을 수 있습니다. 학습률이 낮은 것이 좋지만 모델이 수렴하는 데 더 많은 반복이 필요합니다. 1e-4와 같이 낮은 수준으로 시작하는 것이 좋습니다. 학습이 매우 느리다면 이 값을 높입니다. 모델이 학습하지 않는 경우 학습률을 낮춰 보세요.
sepCNN 모델에만 해당하는 몇 가지 추가 초매개변수가 있습니다.
커널 크기: 컨볼루션 창의 크기입니다. 권장 값은 3 또는 5입니다.
임베딩 차원: 단어 임베딩(즉, 각 단어 벡터의 크기)을 나타내는 데 사용할 차원의 수입니다. 권장 값: 50~300개 실험에서는 사전 학습된 임베딩 레이어가 있는 200차원의 GloVe 임베딩을 사용했습니다.
초매개변수를 살펴보고 가장 효과적인 초매개변수를 확인하세요. 사용 사례에서 성능이 가장 좋은 초매개변수를 선택하면 모델을 배포할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 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."]]