Optuna – Epoch vs Trial Optuna – Epoch 与 Trial

huangapple go评论59阅读模式
英文:

Optuna - Epoch vs Trial

问题

我正在尝试使用Optuna进行超参数优化来训练模型。
在我的训练函数中,我以每次4张图片的批次传递所有训练图片给模型。

假设我有20张图片,这意味着20/4 = 5个数据集批次会传递给我的模型。我还没有添加"epochs"(轮次)的概念。

现在我将Optuna集成到我的代码中,以找到最佳的学习率和优化器,我得到了不同Optuna试验的输出。Optuna – Epoch vs Trial
Optuna – Epoch 与 Trial

现在我想了解,一个Optuna试验是否等同于一个"epoch"(轮次),因为一个试验已经在批次中遍历了整个数据集?还是说Optuna试验与轮次的概念不同,我需要在我的训练函数中添加代码来引入"epochs"(轮次)?

英文:

I am trying to train a model using optuna for hyperparameter optimization.
Now in my train function, I am passing all all the train images in the dataset to that model in batches of 4.

Say I have 20 images so that means 20/4 = 5 batches of my dataset are being passed to my model. I have not added the concept of epochs.

Now I integrate optuna into my code to find the best learning rate and optimizer and I get the output for different trials of optuna. Optuna – Epoch vs Trial
Optuna – Epoch 与 Trial

Now I want to understand that does one trial mean one epoch since one trial has gone over my entire dataset in batches? Or do trials work differently from epochs and I will have to add code to introduce epochs into my train function?

答案1

得分: 1

一个时期(epoch)在你完成整个数据集或所有批次的遍历后结束。大多数复杂模型,如深度神经网络,需要多个时期才能表现良好。

在你的情况下,如果你的模型在性能稳定之前需要多次通过训练数据集,那么你应该在你的Optuna目标函数内添加代码,以在试验期间执行多个时期。试验是对你的目标函数的单次调用,它应该返回模型的评估结果。试验的目的是评估一组超参数,如果在评估之前模型没有经过足够的时期训练,这个评估将会误导。

英文:

An epoch is completed when you have passed through the whole dataset, or all of the batches. Most complex models such as deep neural networks require multiple epochs to perform well.

In your case if your model requires multiple passes through the training dataset before its performance stabilizes, then you should add code within your optuna objective function to perform multiple epochs during a trial. A trial is a single call to your objective function, which should return an evaluation of the model. The purpose of a trial is to assess a set of hyperparameters, and this assessment will be misleading if the model is not trained for enough epochs before it is evaluated.

huangapple
  • 本文由 发表于 2023年7月3日 16:10:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76602930.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定