error: `eval_accuracy` not included

#74
by pchiang5 - opened

Thank you for providing Geneformer. When I tried hyperparamter training with the input below:

set training arguments

training_args = {
"do_train": True,
"do_eval": True,
"evaluation_strategy": "steps",
"eval_steps": logging_steps,
"logging_steps": logging_steps,
"group_by_length": True,
"save_steps": 7248,
"length_column_name": "length",
"disable_tqdm": True,
"skip_memory_metrics": True, # memory tracker causes errors in raytune
"per_device_train_batch_size": geneformer_batch_size,
"per_device_eval_batch_size": geneformer_batch_size,
"num_train_epochs": epochs,
"load_best_model_at_end": True, #original true
"output_dir": output_dir,
}

training_args_init = TrainingArguments(**training_args)

create the trainer

trainer = Trainer(
model_init=model_init,
args=training_args_init,
data_collator=DataCollatorForCellClassification(),
train_dataset=classifier_trainset,
eval_dataset=classifier_validset,
compute_metrics=compute_metrics,
)

specify raytune hyperparameter search space

ray_config = {
"num_train_epochs": tune.choice([epochs]),
"learning_rate": tune.loguniform(1e-6, 1e-3),
"weight_decay": tune.uniform(0.0, 0.3),
"lr_scheduler_type": tune.choice(["linear","cosine","polynomial"]),
"warmup_steps": tune.uniform(100, 2000),
"seed": tune.uniform(0,100),
"per_device_train_batch_size": tune.choice([geneformer_batch_size])
}

hyperopt_search = HyperOptSearch(
metric="eval_accuracy", mode="max")

optimize hyperparameters

trainer.hyperparameter_search(
direction="maximize",
backend="ray",
resources_per_trial={"cpu":36,"gpu":1},
hp_space=lambda _: ray_config,
search_alg=hyperopt_search,
n_trials=100, # number of trials
progress_reporter=tune.CLIReporter(max_report_frequency=600,
sort_by_metric=True,
max_progress_rows=100,
mode="max",
metric="eval_accuracy",
metric_columns=["loss", "eval_loss", "eval_accuracy"])
)

The following error occurred. Could you kindly help me locate the problem?

== Status ==
Current time: 2023-06-30 13:08:26 (running for 00:40:00.32)
Using FIFO scheduling algorithm.
Logical resource usage: 36.0/48 CPUs, 1.0/1 GPUs
Result logdir: /root/ray_results/_objective_2023-06-30_12-28-26
Number of trials: 2/100 (1 PENDING, 1 RUNNING)
+---------------------+----------+-----------------------+-----------------+---------------------+--------------------+------------------------+---------+----------------+----------------+
| Trial name | status | loc | learning_rate | lr_scheduler_type | num_train_epochs | per_device_train_bat | seed | warmup_steps | weight_decay |
| | | | | | | ch_size | | | |
|---------------------+----------+-----------------------+-----------------+---------------------+--------------------+------------------------+---------+----------------+----------------|
| _objective_c3280932 | RUNNING | 172.31.110.212:728665 | 6.60963e-06 | polynomial | 1 | 2 | 68.3648 | 1617.92 | 0.150326 |
| _objective_bd8a2bfc | PENDING | | 0.000120052 | linear | 1 | 2 | 17.703 | 1592.29 | 0.2757 |
+---------------------+----------+-----------------------+-----------------+---------------------+--------------------+------------------------+---------+----------------+----------------+

(_objective pid=728665) {'loss': 0.9496, 'learning_rate': 6.0923637356386e-06, 'epoch': 0.1}
(_objective pid=728665) {'eval_runtime': 0.001, 'eval_samples_per_second': 0.0, 'eval_steps_per_second': 0.0, 'epoch': 0.1}
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/tune_controller.py:815 in โ”‚
โ”‚ _on_result โ”‚
โ”‚ โ”‚
โ”‚ 812 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ f"{args}, {kwargs}" โ”‚
โ”‚ 813 โ”‚ โ”‚ โ”‚ โ”‚ ) โ”‚
โ”‚ 814 โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚
โ”‚ โฑ 815 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ on_result(trial, *args, **kwargs) โ”‚
โ”‚ 816 โ”‚ โ”‚ โ”‚ โ”‚ except Exception as e: โ”‚
โ”‚ 817 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ logger.debug( โ”‚
โ”‚ 818 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ f"Error handling {method_name.upper()} result " โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py:735 in โ”‚
โ”‚ _on_training_result โ”‚
โ”‚ โ”‚
โ”‚ 732 โ”‚ โ”‚ if not isinstance(result, list): โ”‚
โ”‚ 733 โ”‚ โ”‚ โ”‚ result = [result] โ”‚
โ”‚ 734 โ”‚ โ”‚ with warn_if_slow("process_trial_result"): โ”‚
โ”‚ โฑ 735 โ”‚ โ”‚ โ”‚ self._process_trial_results(trial, result) โ”‚
โ”‚ 736 โ”‚ โ”‚ self._maybe_execute_queued_decision(trial) โ”‚
โ”‚ 737 โ”‚ โ”‚
โ”‚ 738 โ”‚ def _process_trial_results(self, trial, results): โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py:748 in โ”‚
โ”‚ _process_trial_results โ”‚
โ”‚ โ”‚
โ”‚ 745 โ”‚ โ”‚ ): โ”‚
โ”‚ 746 โ”‚ โ”‚ โ”‚ for i, result in enumerate(results): โ”‚
โ”‚ 747 โ”‚ โ”‚ โ”‚ โ”‚ with warn_if_slow("process_trial_result"): โ”‚
โ”‚ โฑ 748 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ decision = self._process_trial_result(trial, result) โ”‚
โ”‚ 749 โ”‚ โ”‚ โ”‚ โ”‚ if decision is None: โ”‚
โ”‚ 750 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ # If we didn't get a decision, this means a โ”‚
โ”‚ 751 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ # non-training future (e.g. a save) was scheduled. โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py:785 in โ”‚
โ”‚ _process_trial_result โ”‚
โ”‚ โ”‚
โ”‚ 782 โ”‚ โ”‚ self._total_time += result.get(TIME_THIS_ITER_S, 0) โ”‚
โ”‚ 783 โ”‚ โ”‚ โ”‚
โ”‚ 784 โ”‚ โ”‚ flat_result = flatten_dict(result) โ”‚
โ”‚ โฑ 785 โ”‚ โ”‚ self._validate_result_metrics(flat_result) โ”‚
โ”‚ 786 โ”‚ โ”‚ โ”‚
โ”‚ 787 โ”‚ โ”‚ if self._stopper(trial.trial_id, result) or trial.should_stop(flat_result): โ”‚
โ”‚ 788 โ”‚ โ”‚ โ”‚ decision = TrialScheduler.STOP โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py:883 in โ”‚
โ”‚ _validate_result_metrics โ”‚
โ”‚ โ”‚
โ”‚ 880 โ”‚ โ”‚ โ”‚ โ”‚ location = None โ”‚
โ”‚ 881 โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ 882 โ”‚ โ”‚ โ”‚ if report_metric: โ”‚
โ”‚ โฑ 883 โ”‚ โ”‚ โ”‚ โ”‚ raise ValueError( โ”‚
โ”‚ 884 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ "Trial returned a result which did not include the " โ”‚
โ”‚ 885 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ "specified metric(s) {} that {} expects. " โ”‚
โ”‚ 886 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ "Make sure your calls to tune.report() include the " โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
ValueError: Trial returned a result which did not include the specified metric(s) eval_accuracy that SearchGenerator
expects. Make sure your calls to tune.report() include the metric, or set the TUNE_DISABLE_STRICT_METRIC_CHECKING
environment variable to 1. Result: {'objective': None, 'eval_runtime': 0.001, 'eval_samples_per_second': 0.0,
'eval_steps_per_second': 0.0, 'epoch': 0.1, 'time_this_iter_s': 2627.347311973572, 'done': False, 'training_iteration':
1, 'trial_id': 'c3280932', 'date': '2023-06-30_13-12-17', 'timestamp': 1688101937, 'time_total_s': 2627.347311973572,
'pid': 728665, 'hostname': 'DESKTOP-6FHRRIO', 'node_ip': '172.31.110.212', 'time_since_restore': 2627.347311973572,
'iterations_since_restore': 1, 'config/num_train_epochs': 1, 'config/learning_rate': 6.609632605618226e-06,
'config/weight_decay': 0.15032619764660335, 'config/lr_scheduler_type': 'polynomial', 'config/warmup_steps':
1617.919440294964, 'config/seed': 68.36480039671002, 'config/per_device_train_batch_size': 2}

During handling of the above exception, another exception occurred:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ in :2 โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/transformers/trainer.py:2628 in โ”‚
โ”‚ hyperparameter_search โ”‚
โ”‚ โ”‚
โ”‚ 2625 โ”‚ โ”‚ โ”‚ HPSearchBackend.SIGOPT: run_hp_search_sigopt, โ”‚
โ”‚ 2626 โ”‚ โ”‚ โ”‚ HPSearchBackend.WANDB: run_hp_search_wandb, โ”‚
โ”‚ 2627 โ”‚ โ”‚ } โ”‚
โ”‚ โฑ 2628 โ”‚ โ”‚ best_run = backend_dict[backend](self, n_trials, direction, **kwargs) โ”‚
โ”‚ 2629 โ”‚ โ”‚ โ”‚
โ”‚ 2630 โ”‚ โ”‚ self.hp_search_backend = None โ”‚
โ”‚ 2631 โ”‚ โ”‚ return best_run โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/transformers/integrations.py:353 in โ”‚
โ”‚ run_hp_search_ray โ”‚
โ”‚ โ”‚
โ”‚ 350 โ”‚ if hasattr(trainable, "mixins"): โ”‚
โ”‚ 351 โ”‚ โ”‚ dynamic_modules_import_trainable.mixins = trainable.mixins โ”‚
โ”‚ 352 โ”‚ โ”‚
โ”‚ โฑ 353 โ”‚ analysis = ray.tune.run( โ”‚
โ”‚ 354 โ”‚ โ”‚ dynamic_modules_import_trainable, โ”‚
โ”‚ 355 โ”‚ โ”‚ config=trainer.hp_space(None), โ”‚
โ”‚ 356 โ”‚ โ”‚ num_samples=n_trials, โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/tune.py:1070 in run โ”‚
โ”‚ โ”‚
โ”‚ 1067 โ”‚ โ”‚ โ”‚ while ( โ”‚
โ”‚ 1068 โ”‚ โ”‚ โ”‚ โ”‚ not runner.is_finished() and not experiment_interrupted_event.is_set() โ”‚
โ”‚ 1069 โ”‚ โ”‚ โ”‚ ): โ”‚
โ”‚ โฑ 1070 โ”‚ โ”‚ โ”‚ โ”‚ runner.step() โ”‚
โ”‚ 1071 โ”‚ โ”‚ โ”‚ โ”‚ if has_verbosity(Verbosity.V1_EXPERIMENT): โ”‚
โ”‚ 1072 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ _report_progress(runner, progress_reporter) โ”‚
โ”‚ 1073 โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/tune_controller.py:256 in โ”‚
โ”‚ step โ”‚
โ”‚ โ”‚
โ”‚ 253 โ”‚ โ”‚ self._maybe_add_actors() โ”‚
โ”‚ 254 โ”‚ โ”‚ โ”‚
โ”‚ 255 โ”‚ โ”‚ # Handle one event โ”‚
โ”‚ โฑ 256 โ”‚ โ”‚ if not self._actor_manager.next(timeout=0.1): โ”‚
โ”‚ 257 โ”‚ โ”‚ โ”‚ # If there are no actors running, warn about potentially โ”‚
โ”‚ 258 โ”‚ โ”‚ โ”‚ # insufficient resources โ”‚
โ”‚ 259 โ”‚ โ”‚ โ”‚ if not self._actor_manager.num_live_actors: โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/air/execution/_internal/actor_manager.py:22 โ”‚
โ”‚ 4 in next โ”‚
โ”‚ โ”‚
โ”‚ 221 โ”‚ โ”‚ if future in actor_state_futures: โ”‚
โ”‚ 222 โ”‚ โ”‚ โ”‚ self._actor_state_events.resolve_future(future) โ”‚
โ”‚ 223 โ”‚ โ”‚ elif future in actor_task_futures: โ”‚
โ”‚ โฑ 224 โ”‚ โ”‚ โ”‚ self._actor_task_events.resolve_future(future) โ”‚
โ”‚ 225 โ”‚ โ”‚ else: โ”‚
โ”‚ 226 โ”‚ โ”‚ โ”‚ self._handle_ready_resource_future() โ”‚
โ”‚ 227 โ”‚ โ”‚ โ”‚ # Ready resource futures don't count as one event as they don't trigger โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/air/execution/_internal/event_manager.py:11 โ”‚
โ”‚ 8 in resolve_future โ”‚
โ”‚ โ”‚
โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”‚ raise e โ”‚
โ”‚ 116 โ”‚ โ”‚ else: โ”‚
โ”‚ 117 โ”‚ โ”‚ โ”‚ if on_result: โ”‚
โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ โ”‚ on_result(result) โ”‚
โ”‚ 119 โ”‚ โ”‚
โ”‚ 120 โ”‚ def wait( โ”‚
โ”‚ 121 โ”‚ โ”‚ self, โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/air/execution/_internal/actor_manager.py:75 โ”‚
โ”‚ 2 in on_result โ”‚
โ”‚ โ”‚
โ”‚ 749 โ”‚ โ”‚ โ”‚ ) from e โ”‚
โ”‚ 750 โ”‚ โ”‚ โ”‚
โ”‚ 751 โ”‚ โ”‚ def on_result(result: Any): โ”‚
โ”‚ โฑ 752 โ”‚ โ”‚ โ”‚ self._actor_task_resolved( โ”‚
โ”‚ 753 โ”‚ โ”‚ โ”‚ โ”‚ tracked_actor_task=tracked_actor_task, result=result โ”‚
โ”‚ 754 โ”‚ โ”‚ โ”‚ ) โ”‚
โ”‚ 755 โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/air/execution/_internal/actor_manager.py:30 โ”‚
โ”‚ 0 in _actor_task_resolved โ”‚
โ”‚ โ”‚
โ”‚ 297 โ”‚ โ”‚ โ”‚
โ”‚ 298 โ”‚ โ”‚ # Trigger actor task result callback โ”‚
โ”‚ 299 โ”‚ โ”‚ if tracked_actor_task._on_result: โ”‚
โ”‚ โฑ 300 โ”‚ โ”‚ โ”‚ tracked_actor_task._on_result(tracked_actor, result) โ”‚
โ”‚ 301 โ”‚ โ”‚
โ”‚ 302 โ”‚ def _handle_ready_resource_future(self): โ”‚
โ”‚ 303 โ”‚ โ”‚ """Handle a resource future that became ready. โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/tune_controller.py:824 in โ”‚
โ”‚ _on_result โ”‚
โ”‚ โ”‚
โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ if e is TuneError or self._fail_fast == self.RAISE: โ”‚
โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ raise e โ”‚
โ”‚ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ else: โ”‚
โ”‚ โฑ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ raise TuneError(traceback.format_exc()) โ”‚
โ”‚ 825 โ”‚ โ”‚ โ”‚
โ”‚ 826 โ”‚ โ”‚ if on_error: โ”‚
โ”‚ 827 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
TuneError: Traceback (most recent call last):
File "/home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/tune_controller.py", line 815, in _on_result
on_result(trial, *args, **kwargs)
File "/home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py", line 735, in
_on_training_result
self._process_trial_results(trial, result)
File "/home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py", line 748, in
_process_trial_results
decision = self._process_trial_result(trial, result)
File "/home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py", line 785, in
_process_trial_result
self._validate_result_metrics(flat_result)
File "/home/pc/miniconda3/lib/python3.10/site-packages/ray/tune/execution/trial_runner.py", line 883, in
_validate_result_metrics
raise ValueError(
ValueError: Trial returned a result which did not include the specified metric(s) eval_accuracy that SearchGenerator
expects. Make sure your calls to tune.report() include the metric, or set the TUNE_DISABLE_STRICT_METRIC_CHECKING
environment variable to 1. Result: {'objective': None, 'eval_runtime': 0.001, 'eval_samples_per_second': 0.0,
'eval_steps_per_second': 0.0, 'epoch': 0.1, 'time_this_iter_s': 2627.347311973572, 'done': False, 'training_iteration':
1, 'trial_id': 'c3280932', 'date': '2023-06-30_13-12-17', 'timestamp': 1688101937, 'time_total_s': 2627.347311973572,
'pid': 728665, 'hostname': 'DESKTOP-6FHRRIO', 'node_ip': '172.31.110.212', 'time_since_restore': 2627.347311973572,
'iterations_since_restore': 1, 'config/num_train_epochs': 1, 'config/learning_rate': 6.609632605618226e-06,
'config/weight_decay': 0.15032619764660335, 'config/lr_scheduler_type': 'polynomial', 'config/warmup_steps':
1617.919440294964, 'config/seed': 68.36480039671002, 'config/per_device_train_batch_size': 2}

BTW, there was another error below when I ran the native code in the notebook:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ in :20 โ”‚
โ”‚ in init:111 โ”‚
โ”‚ โ”‚
โ”‚ /home/pc/miniconda3/lib/python3.10/site-packages/transformers/training_args.py:1251 in โ”‚
โ”‚ post_init โ”‚
โ”‚ โ”‚
โ”‚ 1248 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ "--load_best_model_at_end requires the saving steps to be a โ”‚
โ”‚ 1249 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ f"steps, but found {self.save_steps}, which is not a multipl โ”‚
โ”‚ 1250 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ ) โ”‚
โ”‚ โฑ 1251 โ”‚ โ”‚ โ”‚ โ”‚ raise ValueError( โ”‚
โ”‚ 1252 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ "--load_best_model_at_end requires the saving steps to be a round mu โ”‚
โ”‚ 1253 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ f"steps, but found {self.save_steps}, which is not a round multiple โ”‚
โ”‚ 1254 โ”‚ โ”‚ โ”‚ โ”‚ ) โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
ValueError: --load_best_model_at_end requires the saving steps to be a round multiple of the evaluation steps, but found
453, which is not a round multiple of 7248.

The error could be bypassed by adding "save_steps": 7248 to "training_args". The original ValueError: Trial returned a result which did not include the specified metric(s) eval_accuracy that SearchGenerator expects. Make sure your calls to tune.report() include the metric, or set the TUNE_DISABLE_STRICT_METRIC_CHECKING environment variable to 1. happened after adding that line.

Thank you for your interest in Geneformer. The first error appears to be due to the name in the provided metrics being different than expected by RayTune so I would suggest determining the name it should look for and providing that accordingly. The second error can be solved based on the suggestion Huggingface provides in the error message.

ctheodoris changed discussion status to closed

Thank you for your answers. However, I followed the notebook "hyperparam_optimiz_for_disease_classifier.py" and used your DCM dataset as the test. Moreover, I noted the use of accuracy': acc and not `eval_accuracy': acc' in the following section:

def compute_metrics(pred):
labels = pred.label_ids
preds = pred.predictions.argmax(-1)
# calculate accuracy using sklearn's function
acc = accuracy_score(labels, preds)
return {
'accuracy': acc,
}

So I changed to eval_accuracy and set "save_steps": 7248, but the identical error message jumped out. Do I have to indicate the 'eval_accuracy' otherwhere as the input for SearchGenerator?

pchiang5 changed discussion status to open

Thank you for your question. The example we provided is exactly how we performed the analysis. As you note, the names are different in the definition of the compute_metrics and in the variable name passed to RayTune. We had to arrange it that way because the name was altered from what we had labeled it as. If in your versions it is a different name, you should do the same and determine what the variable is named so that you can indicate it correctly to RayTune. There are a few places within the code where this referenced so I would suggest you modify it in all of those locations. For the "save_steps", it would be more robust to make it a multiple of "logging_steps".

ctheodoris changed discussion status to closed

Thank you. I got it to work by using the organ_trainset and organ_evalset (unmodified) in your cell_classification.ipynb as the input for the hyperparameter optimization. I guess somewhere was messed up during the label assignment with my original trials.

Sign up or log in to comment