Nadmierne dopasowanie: interpretacja krzywych straty
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Uczenie maszynowe byłoby znacznie prostsze, gdyby wszystkie krzywe strat wyglądały tak samo przy pierwszym trenowaniu modelu:
Rysunek 20. Idealna krzywa strat
Niestety krzywe strat są często trudne do zinterpretowania. Wykorzystaj swoją intuicję dotyczącą krzywych strat, aby rozwiązać ćwiczenia na tej stronie.
Ćwiczenie 1. Oscylacyjna krzywa strat
Rysunek 21. Krzywa oscylacyjna utraty.
Jakie 3 rzeczy możesz zrobić, aby poprawić krzywą strat przedstawioną na rysunku 21?
Porównaj swoje dane ze schematem danych, aby wykryć złe przykłady, a potem usuń je ze zbioru treningowego.
Tak, to dobra praktyka w przypadku wszystkich modeli.
zmniejszyć tempo nauki;
Tak, zmniejszanie szybkości uczenia się często jest dobrym pomysłem podczas debugowania problemu z trenowaniem.
Zmniejsz zbiór treningowy do niewielkiej liczby wiarygodnych przykładów.
Chociaż ta technika brzmi sztucznie, w istocie jest dobrym pomysłem. Zakładając, że model zbiega się na małym zbiorze wiarygodnych przykładów, możesz stopniowo dodawać więcej przykładów, aby sprawdzić, które z nich powodują wahania krzywej strat.
Zwiększ liczbę przykładów w zbiorze treningowym.
To kusząca propozycja, ale jest bardzo mało prawdopodobne, że rozwiąże Twój problem.
Zwiększ tempo uczenia się.
Ogólnie unikaj zwiększania szybkości uczenia się, gdy krzywa uczenia się modelu wskazuje na problem.
Ćwiczenie 2. Krzywa strat z ostrym skokiem
Rysunek 22. Gwałtowny wzrost strat.
Które 2 z podanych stwierdzeń wskazują na możliwe przyczyny gwałtownego wzrostu strat widocznego na rysunku 22?
Dane wejściowe zawierają co najmniej 1 wartość NaN, np. wartość spowodowaną dzieleniem przez 0.
Jest to częstsze zjawisko, niż mogłoby się wydawać.
Dane wejściowe zawierają dużą liczbę wartości odstających.
Czasami z powodu nieprawidłowego mieszania partii partia może zawierać wiele wartości odstających.
Zbyt niski współczynnik uczenia się.
Bardzo niskie tempo uczenia się może wydłużyć czas trenowania, ale nie jest przyczyną dziwnej krzywej straty.
Współczynnik regularyzacji jest za wysoki.
To prawda, że bardzo wysoka regularyzacja może uniemożliwić modelowi konwergencję, ale nie spowoduje dziwnej krzywej utraty przedstawionej na rysunku 22.
Ćwiczenie 3. Strata w testach różni się od straty w treningu
Rysunek 23. gwałtowny wzrost strat z powodu nieprawidłowej weryfikacji;
Które z tych stwierdzeń najlepiej opisuje przyczynę tej różnicy między krzywą utraty funkcji celu w przypadku zbiorów danych do trenowania i testowania?
Model zbyt dobrze pasuje do zbioru treningowego.
Tak, prawdopodobnie tak jest. Możliwe rozwiązania:
Uprość model, np. przez zmniejszenie liczby cech.
Zwiększ stopień regularyzacji.
Upewnij się, że zbiór treningowy i testowy są statystycznie równoważne.
Tempo uczenia się jest za wysokie.
Gdyby szybkość uczenia się była zbyt wysoka, krzywa strat dla zbioru treningowego prawdopodobnie nie wyglądałaby tak samo.
Ćwiczenie 4. Krzywa strat się zacina
Rysunek 24. Chaotyczna utrata po określonej liczbie kroków.
Które z tych stwierdzeń jest najbardziej prawdopodobnym wyjaśnieniem nieregularnej krzywej strat pokazanej na rysunku 24?
Zbiór danych do trenowania nie jest dobrze posortowany.
To jest możliwe. Na przykład zbiór treningowy zawierający 100 obrazów psów, a potem 100 obrazów kotów może powodować wahania wartości funkcji utraty podczas trenowania modelu. Dokładnie wymieszaj przykłady.
[null,null,["Ostatnia aktualizacja: 2025-06-02 UTC."],[[["\u003cp\u003eThis document helps you understand and interpret Machine Learning loss curves through a series of exercises and visual examples.\u003c/p\u003e\n"],["\u003cp\u003eYou will learn how to identify common issues like oscillating loss, exploding loss, overfitting, and erratic behavior in your models.\u003c/p\u003e\n"],["\u003cp\u003eSolutions are provided for each exercise, along with explanations for various loss curve patterns.\u003c/p\u003e\n"],["\u003cp\u003eTechniques to address these issues are discussed, including adjusting learning rate, cleaning training data, and applying regularization.\u003c/p\u003e\n"],["\u003cp\u003eA glossary of key Machine Learning terminology related to loss curves and model training is included for quick reference.\u003c/p\u003e\n"]]],[],null,["# Overfitting: Interpreting loss curves\n\nMachine learning would be much simpler if all your\n[**loss curves**](/machine-learning/glossary#loss_curve)\nlooked like this the first time you trained your model:\n**Figure 20.** An ideal loss curve.\n\nUnfortunately, loss curves are often challenging to interpret. Use your\nintuition about loss curves to solve the exercises on this page.\n\nExercise 1: Oscillating loss curve\n----------------------------------\n\n**Figure 21.** Oscillating loss curve. \nWhat **three** things could you do to try improve the loss curve shown in Figure 21? \nCheck your data against a data schema to detect bad examples, and then remove the bad examples from the training set. \nYes, this is a good practice for all models. \nReduce the learning rate. \nYes, reducing learning rate is often a good idea when debugging a training problem. \nReduce the training set to a tiny number of trustworthy examples. \nAlthough this technique sounds artificial, it is actually a good idea. Assuming that the model converges on the small set of trustworthy examples, you can then gradually add more examples, perhaps discovering which examples cause the loss curve to oscillate. \nIncrease the number of examples in the training set. \nThis is a tempting idea, but it is extremely unlikely to fix the problem. \nIncrease the learning rate. \nIn general, avoid increasing the learning rate when a model's learning curve indicates a problem.\n\nExercise 2. Loss curve with a sharp jump\n----------------------------------------\n\n**Figure 22.** Sharp rise in loss. \nWhich **two** of the following statements identify possible reasons for the exploding loss shown in Figure 22? \nThe input data contains one or more NaNs---for example, a value caused by a division by zero. \nThis is more common than you might expect. \nThe input data contains a burst of outliers. \nSometimes, due to improper shuffling of batches, a batch might contain a lot of outliers. \nThe learning rate is too low. \nA very low learning rate might increase training time, but it is not the cause of the strange loss curve. \nThe regularization rate is too high. \nTrue, a very high regularization could prevent a model from converging; however, it won't cause the strange loss curve shown in Figure 22.\n\nExercise 3. Test loss diverges from training loss\n-------------------------------------------------\n\n**Figure 23.** Sharp rise in validation loss. \nWhich **one** of the following statements best identifies the reason for this difference between the loss curves of the training and test sets? \nThe model is overfitting the training set. \nYes, it probably is. Possible solutions:\n\n- Make the model simpler, possibly by reducing the number of features.\n- Increase the regularization rate.\n- Ensure that the training set and test set are statistically equivalent. \nThe learning rate is too high. \nIf the learning rate were too high, the loss curve for the training set would likely not have behaved as it did.\n\nExercise 4. Loss curve gets stuck\n---------------------------------\n\n**Figure 24.** Chaotic loss after a certain number of steps. \nWhich **one** of the following statements is the most likely explanation for the erratic loss curve shown in Figure 24? \nThe training set is not shuffled well. \nThis is a possibility. For example, a training set that contains 100 images of dogs followed by 100 images of cats may cause loss to oscillate as the model trains. Ensure that you shuffle examples sufficiently. \nThe regularization rate is too high. \nThis is unlikely to be the cause. \nThe training set contains too many features. \nThis is unlikely to be the cause.\n| **Key terms:**\n|\n| - [Batch](/machine-learning/glossary#batch)\n| - [Example](/machine-learning/glossary#example)\n| - [Feature](/machine-learning/glossary#feature)\n| - [Learning rate](/machine-learning/glossary#learning-rate)\n| - [Loss curve](/machine-learning/glossary#loss_curve)\n| - [Outliers](/machine-learning/glossary#outliers)\n| - [Overfitting](/machine-learning/glossary#overfitting)\n| - [Regularization](/machine-learning/glossary#regularization)\n| - [Regularization rate](/machine-learning/glossary#regularization-rate)\n| - [Test set](/machine-learning/glossary#test-set)\n| - [Training set](/machine-learning/glossary#training-set)\n- [Validation set](/machine-learning/glossary#validation_set) \n[Help Center](https://support.google.com/machinelearningeducation)"]]