Тримайте все під контролем за допомогою колекцій
Зберігайте контент і організовуйте його за категоріями відповідно до своїх потреб.
Процес машинного навчання був би значно простішим, якби всі ваші криві втрат мали такий вигляд, коли ви вперше навчали свою модель:
Рисунок 20. Ідеальна крива втрат.
Криві втрат часто важко інтерпретувати. Виконуючи вправи на цій сторінці, покладайтеся на свою інтуїцію.
Вправа 1. Коливальна крива втрат
Рисунок 21. Коливальна крива втрат.
Які три дії можна зробити, щоб покращити криву втрат, показану на рисунку 21?
Порівняти відомості зі схемою даних, щоб виявити погані приклади, а потім видалити їх із навчального набору.
Так, це гарний метод для всіх моделей.
Знизити швидкість навчання.
Так, зниження швидкості навчання часто допомагає налагодити його процес.
Скоротити навчальний набір даних до невеликої кількості надійних прикладів.
Хоча здається, що це штучний метод, насправді це хороша ідея. Якщо модель досягає збіжності, коли використовується невеликий набір надійних прикладів, можна поступово додавати їх більшу кількість. Тоді, імовірно, удасться виявити, які з них спричиняють коливання кривої втрат.
Збільшити кількість прикладів у навчальному наборі даних.
Це приваблива ідея, але вона навряд чи вирішить проблему.
Підвищити швидкість навчання.
Зазвичай краще не збільшувати швидкість навчання моделі, якщо відповідна крива вказує на проблему.
Вправа 2. Крива втрат із різким стрибком
Рисунок 22. Різке зростання втрат.
Які два з наведених нижче тверджень – можливі причини різкого зростання втрат, показаного на рисунку 22?
Вхідні дані містять одне або кілька значень NaN (наприклад, значення, отримане в результаті ділення на нуль).
Це трапляється частіше, ніж можна було б очікувати.
Вхідні дані містять велику кількість викидів.
Іноді через неправильне перемішування пакетів в одному з них може бути багато викидів.
Швидкість навчання занизька.
Через занизьку швидкість навчання може збільшитися його тривалість, але це не є причиною дивної кривої втрат.
Коефіцієнт регуляризації зависокий.
Дійсно, дуже сильна регуляризація може перешкодити збіжності моделі, але через неї не виникне дивна крива втрат, показана на рисунку 22.
Вправа 3. Втрати при тестуванні відрізняються від втрат при навчанні
Рисунок 23. Різке зростання втрат при перевірці.
Яке одне з тверджень, наведених нижче, найкраще пояснює, чому криві втрат навчальних і тестових наборів даних так відрізняються?
Модель надмірно пристосовується до навчального набору даних.
Так, це можливо. Нижче наведено варіанти рішень.
Спростіть модель, наприклад, зменшивши кількість ознак.
Збільште коефіцієнт регуляризації.
Переконайтеся, що навчальний і тестовий набори даних статистично рівноцінні.
Швидкість навчання зависока.
Якби швидкість навчання була зависокою, імовірно, крива втрат для навчального набору даних поводилася б інакше.
Вправа 4. Крива втрат зупиняється
Рисунок 24. Хаотична втрата після певної кількості кроків.
Яке одне з тверджень, наведених нижче, – найімовірніша причина нестабільної кривої втрат, показаної на рисунку 24?
Навчальний набір даних містить послідовності прикладів, що повторюються.
Це можливо. Переконайтеся, що ви ретельно перемішуєте приклади.
[null,null,["Останнє оновлення: 2025-04-22 (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)"]]