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.

AttributeError: 'MMBTConfig' object has no attribute 'use_return_dict' in MultiModalClassificationModel

See original GitHub issue

Describe the bug

I receive the exception: AttributeError: ‘MMBTConfig’ object has no attribute ‘use_return_dict’ while training the following model:

model = MultiModalClassificationModel(
     "bert", "bert-base-multilingual-cased", num_labels = 47, args=({'fp16': False,
                                                       'reprocess_input_data': True, 
                                                       'overwrite_output_dir' : True, 
                                                       'num_train_epochs': 5,
                                                       'max_seq_length':128,
                                                       'batch_size':2
                                                       #'evaluate_during_training': True,
                                                       #'logging_steps': 50,

                                                       })
)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
simepycommented, May 4, 2021

Hi @usmanmalik57 !

I fix this problem by adding model.config.use_return_dict = False I find this in the issue #774

I’m now facing to another issue:

Traceback (most recent call last):
  File "/file.py", line 84, in <module>
    model.train_model(train_sample, image_path=image_dir)
  File "pyEnv/lib/python3.9/site-packages/simpletransformers/classification/multi_modal_classification_model.py", line 319, in train_model
    global_step, training_details = self.train(
  File "/pyEnv/lib/python3.9/site-packages/simpletransformers/classification/multi_modal_classification_model.py", line 555, in train
    current_loss = loss.item()
ValueError: only one element tensors can be converted to Python scalars

I launch like this:

arg = MultiModalClassificationArgs()
model = MultiModalClassificationModel(
    'bert',
    'bert-base-multilingual-cased',
    args=arg,
    use_cuda=cuda_available,
    label_list=my_label_list
)

model.config.use_return_dict = False

# Train the model
model.train_model(train_sample, image_path=image_dir)

@ThilinaRajapakse Do you have some clue ?

Thanks in advance

0reactions
Tdrinkercommented, May 29, 2022

Thank you for your reply. I have made the changes you recommend. The model is training successfully, however while making predictions, I get the following error: if isinstance(data, tuple): UnboundLocalError: local variable ‘data’ referenced before assignment

I have been through the same earlier errors that I fixed them by reading this issue. And now I have the same error message local variable 'data' referenced before assignment

Hello I am facing the same issue. Do you have a solution for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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