Skip to content

How to tune number of epochs? #1021

Description

@jajupmochi

Hi, may I ask how I can find best number of epochs (not max_epochs) through cross validation? Is it possible to do something like:

from sklearn.model_selection import GridSearchCV, cross_validate
from skorch import NeuralNetClassifier

net = NeuralNetClassifier(...)
params = {
	'n_epochs': [10, 20, 30, 40, 50],
}
gs = GridSearchCV(
	estimator=net,
	param_grid=params,
	refit=True,
	cv=inner_cv,
	scoring='accuracy',
)
test_predictions = cross_validate(
	gs,
	X,
	y,
	cv=outer_cv,
	scoring=scoring,
	verbose=0,
	n_jobs=n_cores_cv
)
...

If it is possible, may I ask how the models are evaluated on each n_epochs? Is an individual model fitted for each n_epochs, or the valid metrics are calculated and recorded along the training epochs of a single model, so that the model will be fitted only once for one split of dataset?

Thanks!

Activity

  1. locked and limited conversation to collaborators on Sep 1, 2023
  2. converted this issue into a discussion #1022 on Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions