question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: too many values to unpack (expected 2) when using eval_df

See original GitHub issue

Hello, I create the model with this code: model = ClassificationModel( "bert", "dbmdz/bert-base-turkish-uncased",use_cuda=cuda_available,num_labels=num_labels,args={'reprocess_input_data': True, 'overwrite_output_dir': True , 'num_train_epochs': 2,"evaluate_during_training":True, "evaluate_each_epoch":True,"save_best_model":True, "save_model_every_epoch":True,"best_model_dir":"best_bert/"} )

then I call train_model function like this: model.train_model(train_df,eval_df=eval_df)

but after first epoch it return to me too many values to unpack (expected 2) error on here `ValueError Traceback (most recent call last) <ipython-input-28-ab826287928d> in <module> ----> 1 model.train_model(train_df,eval_df=eval_df)

~/.conda/envs/sentiment/lib/python3.6/site-packages/simpletransformers/classification/classification_model.py in train_model(self, train_df, multi_label, output_dir, show_running_loss, args, eval_df, verbose, **kwargs) 610 eval_df=eval_df, 611 verbose=verbose, –> 612 **kwargs, 613 ) 614

~/.conda/envs/sentiment/lib/python3.6/site-packages/simpletransformers/classification/classification_model.py in train(self, train_dataloader, output_dir, multi_label, show_running_loss, eval_df, test_df, verbose, **kwargs) 1180 1181 for key, value in flatten_results( -> 1182 self._get_last_metrics(training_progress_scores) 1183 ): 1184 try:

ValueError: too many values to unpack (expected 2) `

How can I solve this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
b-kaufmancommented, Oct 14, 2021

In fact elsewhere in the code the .items() is present for example: https://github.com/ThilinaRajapakse/simpletransformers/blob/8859e3a9e30900f1575509c7a7a6eb3ddece6cef/simpletransformers/ner/ner_model.py#L1031-L1041 so this seems like a quick fix. It seems like the bug was introduced in pull request #1209

0reactions
ThilinaRajapaksecommented, Nov 3, 2021

This should be fixed now in the latest version (0.62.4)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python valueerror: too many values to unpack (expected 2)
The “valueerror: too many values to unpack (expected 2)” error occurs when you do not unpack all the items in a list. This...
Read more >
ValueError: too many values to unpack (expected 2)
This error occurs when the number of variables doesn't match the number of values. As a result of the inequality, Python doesn't know...
Read more >
python: ValueError: too many values to unpack (expected 2 ...
Tom says "ValueError: too many values to unpack (expected 2) means that you called a function that only returns a single value".
Read more >
too many values to unpack (expected 2) in Python
The Python "ValueError: too many values to unpack (expected 2) in Python" occurs when the number of variables in the assignment is not...
Read more >
ValueError: too many values to unpack (expected 2)
Python ValueError: too many values to unpack, occurs during a multiple-assignment where you either don't have enough objects to assign to the variables...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found