Detecting overfitting in deep learning in a regression task2019 Community Moderator ElectionEarlystopping in multi-output deep learningCheckers playing Neural Network evolved with Genetic Algorithm becomes too sensitive to input data changesConvolution Neural Network Loss and performancePredict task durationHow to improve loss and avoid overfittingTest data predictions yield random results when making predictions from a saved modelValidation loss keeps fluctuating about training lossUsing deep learning to classify similar imagesBias-variance tradeoff in practice (CNN)Remedies to CNN-LSTM overfitting on relatively small image dataset

How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?

Either or Neither in sentence with another negative

Why do I get two different answers for this counting problem?

Why is consensus so controversial in Britain?

Why not use SQL instead of GraphQL?

What is the word for reserving something for yourself before others do?

The use of multiple foreign keys on same column in SQL Server

can i play a electric guitar through a bass amp?

US citizen flying to France today and my passport expires in less than 2 months

What defenses are there against being summoned by the Gate spell?

Today is the Center

Font hinting is lost in Chrome-like browsers (for some languages )

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

What's the output of a record cartridge playing an out-of-speed record

Risk of getting Chronic Wasting Disease (CWD) in the United States?

Mathematical cryptic clues

Do I have a twin with permutated remainders?

What is the offset in a seaplane's hull?

Email Account under attack (really) - anything I can do?

Pattern match does not work in bash script

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Smoothness of finite-dimensional functional calculus

Why do falling prices hurt debtors?

What would happen to a modern skyscraper if it rains micro blackholes?



Detecting overfitting in deep learning in a regression task



2019 Community Moderator ElectionEarlystopping in multi-output deep learningCheckers playing Neural Network evolved with Genetic Algorithm becomes too sensitive to input data changesConvolution Neural Network Loss and performancePredict task durationHow to improve loss and avoid overfittingTest data predictions yield random results when making predictions from a saved modelValidation loss keeps fluctuating about training lossUsing deep learning to classify similar imagesBias-variance tradeoff in practice (CNN)Remedies to CNN-LSTM overfitting on relatively small image dataset










0












$begingroup$


I have regression task at hand, but I am not sure how to consistently detect/prevent overfitting.



As my code's currently written, it will save the model on each epoch as long as



  • the validation loss is lower than a tracked min_valid_loss;

  • the difference between the training loss and the validation loss is not more than threshold, which is an arbitrary number.

The latter is necessary, I feel, to ensure that the model is not saved when the loss curves start diverging too much (particularly in case where training loss keeps decreasing but validation loss starts to increase). My issue is that I don't like the arbitrariness of this number. Let's say that I put threshold to 0.2, then the model will be saved as long as the difference between training and validation loss is less than 0.2. But that value is not based on anything.



Are there any guidelines to deal with this issue?



As a verbose, incomplete example of what the current code looks like (PyTorch, ReduceLROnPlateau scheduler):



threshold = 0.2
valid_loss_min = np.inf
for e in range(epochs):
# list of losses (one per batch)
train_losses = train(...)
valid_losses = validate(...)

train_loss = np.mean(train_losses)
valid_loss = np.mean(valid_losses)

if valid_loss <= valid_loss_min:
if valid_loss - train_loss < threshold:
torch.save(model.state_dict(), 'checkpoint.pth')

scheduler.step(valid_loss)









share|improve this question











$endgroup$











  • $begingroup$
    there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
    $endgroup$
    – honar.cs
    Mar 27 at 16:47















0












$begingroup$


I have regression task at hand, but I am not sure how to consistently detect/prevent overfitting.



As my code's currently written, it will save the model on each epoch as long as



  • the validation loss is lower than a tracked min_valid_loss;

  • the difference between the training loss and the validation loss is not more than threshold, which is an arbitrary number.

The latter is necessary, I feel, to ensure that the model is not saved when the loss curves start diverging too much (particularly in case where training loss keeps decreasing but validation loss starts to increase). My issue is that I don't like the arbitrariness of this number. Let's say that I put threshold to 0.2, then the model will be saved as long as the difference between training and validation loss is less than 0.2. But that value is not based on anything.



Are there any guidelines to deal with this issue?



As a verbose, incomplete example of what the current code looks like (PyTorch, ReduceLROnPlateau scheduler):



threshold = 0.2
valid_loss_min = np.inf
for e in range(epochs):
# list of losses (one per batch)
train_losses = train(...)
valid_losses = validate(...)

train_loss = np.mean(train_losses)
valid_loss = np.mean(valid_losses)

if valid_loss <= valid_loss_min:
if valid_loss - train_loss < threshold:
torch.save(model.state_dict(), 'checkpoint.pth')

scheduler.step(valid_loss)









share|improve this question











$endgroup$











  • $begingroup$
    there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
    $endgroup$
    – honar.cs
    Mar 27 at 16:47













0












0








0





$begingroup$


I have regression task at hand, but I am not sure how to consistently detect/prevent overfitting.



As my code's currently written, it will save the model on each epoch as long as



  • the validation loss is lower than a tracked min_valid_loss;

  • the difference between the training loss and the validation loss is not more than threshold, which is an arbitrary number.

The latter is necessary, I feel, to ensure that the model is not saved when the loss curves start diverging too much (particularly in case where training loss keeps decreasing but validation loss starts to increase). My issue is that I don't like the arbitrariness of this number. Let's say that I put threshold to 0.2, then the model will be saved as long as the difference between training and validation loss is less than 0.2. But that value is not based on anything.



Are there any guidelines to deal with this issue?



As a verbose, incomplete example of what the current code looks like (PyTorch, ReduceLROnPlateau scheduler):



threshold = 0.2
valid_loss_min = np.inf
for e in range(epochs):
# list of losses (one per batch)
train_losses = train(...)
valid_losses = validate(...)

train_loss = np.mean(train_losses)
valid_loss = np.mean(valid_losses)

if valid_loss <= valid_loss_min:
if valid_loss - train_loss < threshold:
torch.save(model.state_dict(), 'checkpoint.pth')

scheduler.step(valid_loss)









share|improve this question











$endgroup$




I have regression task at hand, but I am not sure how to consistently detect/prevent overfitting.



As my code's currently written, it will save the model on each epoch as long as



  • the validation loss is lower than a tracked min_valid_loss;

  • the difference between the training loss and the validation loss is not more than threshold, which is an arbitrary number.

The latter is necessary, I feel, to ensure that the model is not saved when the loss curves start diverging too much (particularly in case where training loss keeps decreasing but validation loss starts to increase). My issue is that I don't like the arbitrariness of this number. Let's say that I put threshold to 0.2, then the model will be saved as long as the difference between training and validation loss is less than 0.2. But that value is not based on anything.



Are there any guidelines to deal with this issue?



As a verbose, incomplete example of what the current code looks like (PyTorch, ReduceLROnPlateau scheduler):



threshold = 0.2
valid_loss_min = np.inf
for e in range(epochs):
# list of losses (one per batch)
train_losses = train(...)
valid_losses = validate(...)

train_loss = np.mean(train_losses)
valid_loss = np.mean(valid_losses)

if valid_loss <= valid_loss_min:
if valid_loss - train_loss < threshold:
torch.save(model.state_dict(), 'checkpoint.pth')

scheduler.step(valid_loss)






deep-learning regression overfitting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 13:51







Bram Vanroy

















asked Mar 27 at 13:37









Bram VanroyBram Vanroy

359




359











  • $begingroup$
    there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
    $endgroup$
    – honar.cs
    Mar 27 at 16:47
















  • $begingroup$
    there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
    $endgroup$
    – honar.cs
    Mar 27 at 16:47















$begingroup$
there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
$endgroup$
– honar.cs
Mar 27 at 16:47




$begingroup$
there is no such standard to tell you what is a good threshold between training and validation accuracy that tells the model is not overfitted, the smaller gap between these two is better, for example, 1%, 2%, 3% like that.
$endgroup$
– honar.cs
Mar 27 at 16:47










0






active

oldest

votes












Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48083%2fdetecting-overfitting-in-deep-learning-in-a-regression-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Data Science Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48083%2fdetecting-overfitting-in-deep-learning-in-a-regression-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High