sktime / pytorch-forecasting

Time series forecasting with PyTorch
https://pytorch-forecasting.readthedocs.io/
MIT License
3.87k stars 612 forks source link

optimize_hyperparameters only runs for 1 epoch on lots of trials #736

Closed YojoNick closed 2 years ago

YojoNick commented 2 years ago

Expected behavior

I executed code optimize_hyperparameters and expected each of the trials to run to max_epochs.

Actual behavior

However, for the 177 trials that were run, 100 of them had only run for a single epoch. Is this to be expected? What would cause, for a given trial, for optimize_hyperparameters to run for only a single epoch and for others to run for the max epochs (50)?

Code to reproduce the problem

    study = optimize_hyperparameters(
        trainDL,
        valDL,
        model_path=params['modelPath'],
        n_trials=200,
        timeout=3600*90, #90 hours
        max_epochs=50,
        gradient_clip_val_range=(1e-2, 1e2),
        hidden_size_range=\
            (params['hiddenSizeStart'], params['hiddenSizeStop']),
        hidden_continuous_size_range=(10,320),
        attention_head_size_range= (1, 4),
        learning_rate_range=(1e-4, 1e-2),
        dropout_range=(0.1, 0.9),
        trainer_kwargs=dict(limit_train_batches=30),
        reduce_on_plateau_patience=4,
        use_learning_rate_finder=False,  
    )
jdb78 commented 2 years ago

You can use a custom pruner to modify the tuning behaviour.

omkarmutreja12 commented 2 years ago

@YojoNick - Hey could you please tell me how did you resolve this? I'm using optimize_hyperparameters function of pytorch forecasting for Temporal fusion transformer and in 10 epochs only 1st two get printed, rest are pruned