Open Zjq9409 opened 1 year ago
Hi, we have supported the request you propose in https://github.com/intel-analytics/BigDL/pull/6826.
we provide a new mode
parameter for trainer.search:
model = CustomModel(
out_dim = space.Categorical(16,32),
dropout = space.Categorical(0.1,0.2),
learning_rate = space.Real(0.001,0.01,log=True),
batch_size = space.Categorical(32,64)
)
trainer = Trainer(
logger=True,
checkpoint_callback=False,
max_epochs=2,
use_hpo=True,
)
best_model = trainer.search(
model,
target_metric='val_loss',
direction='minimize',
n_trials=4,
max_epochs=3,
mode='best', # default value is best, you can change to last.
)
and if you don't specify this parameter, it will select model based on the best results which I think is exactly your need.
You can have a try at your side : )
One note here, only tomorrow's nightly build version or later will have this new feature.
Bigdl-nano Auto_Ml selects the model based on the last epoch loss, needs to be modified to select the one with the highest accuracy. for example, The Actual output Best trial Value is 0.4935064911842346 (the last epoch), but the model needs to be selected according to the best epoch.