NameError: name 'wandb' is not defined
See original GitHub issueDescribe the bug When try to train a classification model with wandb I get this error in google colab.
_Traceback (most recent call last): File “/usr/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap self.run() File “/usr/lib/python3.6/multiprocessing/process.py”, line 93, in run self._target(*self._args, **self._kwargs) File “/usr/local/lib/python3.6/dist-packages/wandb/wandb_agent.py”, line 64, in start function() File “<ipython-input-8-9419ea4c148f>”, line 19, in trainMultiClass f1=f1_multiclass, acc=accuracy_score) File “/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/classification_model.py”, line 269, in train_model **kwargs, File “/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/classification_model.py”, line 373, in train wandb.init(project=args[“wandb_project”], config={**args}, **args[“wandb_kwargs”]) NameError: name ‘wandb’ is not defined
To Reproduce
import wandb
sweep_config = {
'method': 'bayes', #grid, random, bayes
'metric': {
'name': 'eval_loss',
'goal': 'minimize'
},
'parameters': {
'learning_rate': {
'values': [ 5e-5, 3e-5, 4e-5, 2e-5] #4e-5
},
'epochs': {
'values': [1, 2] #2
},
'max_seq_length': { #174
'min': 128,
'max': 200
},
'train_batch_size': {
'values': [8, 16, 32] #16
},
'warmup_ratio': { #0.07478
'min': 0.04,
'max': 0.08
},
'warmup_steps': {
'min': 0,
'max': 100,
}
}
}
sweep_id = wandb.sweep(sweep_config,project="sectors")
def f1_multiclass(labels, preds):
return f1_score(labels, preds, average='micro')
def trainMultiClass():
wandb.init()
print("HyperParams=>>", wandb.config)
num_labels = len(sector_to_id.keys())
model = ClassificationModel('bert', 'bert-base-uncased', num_labels=11)
model.train_model(train, output_dir='bert-uncased-sector', eval_df=test, args={'overwrite_output_dir': True,
'num_train_epochs': wandb.config.epochs,
'learning_rate': wandb.config.learning_rate,
'wandb_project': "sectors",
'evaluate_during_training': True,
'evaluate_during_training_steps': 100,
'max_seq_length': wandb.config.max_seq_length,
'train_batch_size': wandb.config.train_batch_size,
'warmup_ratio': wandb.config.warmup_ratio,
'warmup_steps': wandb.config.warmup_steps},
f1=f1_multiclass, acc=accuracy_score)
wandb.agent(sweep_id,function=trainMultiClass)
Expected behavior Four days ago it worked perfectly I didn’t get any error.
Desktop (please complete the following information):
- Google colab
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Now it’s working again. I don’t know if wandb changed something or I made a mistake because I had had two times “from simpletransformers.classification import ClassificationModel”.
Thanks for your excellent library.
Maybe its a temporally error with colab or wandb. Thanks for your help.