I am doing hyperparamater optimization with wandb sweep. I defined epoch, learning_rate and other values in the parameters, and then past them to the wandb command. However, when I run sweep, it always shows error "run_ner.py: error: argument --learning_rate: invalid float value: '${learning_rate}'", or "${epoch}, ${batch_size}". It seems every variable I referred to using ${VAR} wasn't processed correctly.
Here is an example of my sweep.yaml
program: run_ner.py
method: random
metric:
name: f1
goal: maximize
parameters:
batch_size:
values: [16, 32, 64, 128]
model_name_or_path:
values: ["a_bert_model","b_bert_model"]
weight_decay:
distribution: "uniform"
min: 0.0
max: 0.1
learning_rate:
distribution: "uniform"
min: 0.001
max: 0.01
epochs:
values: [400]
datadir:
values: ["fullData","partialData"]
max_seq_length:
values: [128, 256, 512]
do_lower_case:
values: [True, False]
pad_to_max_length:
values: [True, False]
command:
- ${env}
- python
- run_ner.py
- --model_name_or_path=${model_name_or_path}
- --train_file="temp"
- --do_train
- --validation_file="temp"
- --test_file="temp"
- --do_predict
- --do_eval
- --num_train_epochs=${epochs}
- --text_column_name="words"
- --label_column_name="labels"
- --seed=42
- --per_device_train_batch_size=${batch_size}
- --per_device_eval_batch_size=${batch_size}
- --learning_rate=${learning_rate}
- --weight_decay=${weight_decay}
- --label_all_tokens=True
- --load_best_model_at_end=True
- --save_strategy=steps
- --evaluation_strategy=epoch
- --logging_strategy=epoch
- --max_seq_length=${max_seq_length}
- --pad_to_max_length=${pad_to_max_length}
- --output_dir="outputs/"
And a snippet of the execution output.
run_ner.py: error: argument --learning_rate: invalid float value: '${learning_rate}'
2024-03-04 13:22:56,058 - wandb.wandb_agent - INFO - Agent received command: run
2024-03-04 13:22:56,058 - wandb.wandb_agent - INFO - Agent starting run with config:
datadir: fullData
do_lower_case: True
learning_rate: 0.0067381448491156066
max_seq_length: 512
model_name_or_path: a_bert_model
pad_to_max_length: False
weight_decay: 0.003210073163495664
2024-03-04 13:22:56,071 - wandb.wandb_agent - INFO - About to run command: /usr/bin/env python run_ner.py --model_name_or_path=${model_name_or_path} --train_file="temp" --do_train --validation_file="temp" --test_file="temp" --do_predict --do_eval --num_train_epochs=400 --text_column_name="words" --label_column_name="labels" --seed=42 --per_device_train_batch_size=32 --per_device_eval_batch_size=32 --learning_rate=${learning_rate} --weight_decay=${weight_decay} --label_all_tokens=True --load_best_model_at_end=True --save_strategy=steps --evaluation_strategy=epoch --logging_strategy=epoch --max_seq_length=${max_seq_length} --pad_to_max_length=${pad_to_max_length} --output_dir="outputs/"