May I ask how I can find best number of epochs (not max_epochs) through cross validation when using skorch?
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?