Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error while making model #41

Closed
ahujaravinder022 opened this issue Nov 12, 2019 · 7 comments
Closed

getting error while making model #41

ahujaravinder022 opened this issue Nov 12, 2019 · 7 comments

Comments

@ahujaravinder022
Copy link

Hello
I am getting this error while creating model

ValueError: 'use_cuda' set to True when cuda is unavailable. Make sure CUDA is available or set use_cuda=False.

Describe the bug
A clear and concise description of what the bug is. Please specify the class causing the issue.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS

Additional context
Add any other context about the problem here.

@ThilinaRajapakse
Copy link
Owner

Well, the error is telling you what the issue is. Simple Transformers will try to use CUDA by default. If it's not available, you have to specify use_cuda=False when creating the model.

model = ClassificationModel('bert', 'bert-base-cased', use_cuda=False)

@ahujaravinder022
Copy link
Author

Thanks for your reply. Now I got the error while training the model:
ValueError: too many dimensions 'str'

@ThilinaRajapakse
Copy link
Owner

Please give more details about the issue.

Describe the bug
A clear and concise description of what the bug is. Please specify the class causing the issue.

@ahujaravinder022
Copy link
Author

ValueError Traceback (most recent call last)
in
8 model = MultiLabelClassificationModel('roberta', 'roberta-base', num_labels=6, args={'train_batch_size':2, 'gradient_accumulation_steps':16, 'learning_rate': 3e-5, 'num_train_epochs': 3, 'max_seq_length': 512}, use_cuda=False)
9
---> 10 model.train_model(train_df)

~\Anaconda3\envs\simpletransformers\lib\site-packages\simpletransformers\classification\multi_label_classification_model.py in train_model(self, train_df, multi_label, output_dir, show_running_loss, args)
97
98 def train_model(self, train_df, multi_label=True, output_dir=None, show_running_loss=True, args=None):
---> 99 return super().train_model(train_df, multi_label=multi_label, output_dir=output_dir, show_running_loss=show_running_loss, args=args)
100
101 def eval_model(self, eval_df, multi_label=True, output_dir=None, verbose=False, **kwargs):

~\Anaconda3\envs\simpletransformers\lib\site-packages\simpletransformers\classification\classification_model.py in train_model(self, train_df, multi_label, output_dir, show_running_loss, args, eval_df)
157
158
--> 159 train_dataset = self.load_and_cache_examples(train_examples)
160 global_step, tr_loss = self.train(train_dataset, output_dir, show_running_loss=show_running_loss, eval_df=eval_df)
161

~\Anaconda3\envs\simpletransformers\lib\site-packages\simpletransformers\classification\multi_label_classification_model.py in load_and_cache_examples(self, examples, evaluate, no_cache, multi_label)
106
107 def load_and_cache_examples(self, examples, evaluate=False, no_cache=False, multi_label=True):
--> 108 return super().load_and_cache_examples(examples, evaluate=evaluate, no_cache=no_cache, multi_label=multi_label)
109
110 def compute_metrics(self, preds, labels, eval_examples, multi_label=True, **kwargs):

~\Anaconda3\envs\simpletransformers\lib\site-packages\simpletransformers\classification\classification_model.py in load_and_cache_examples(self, examples, evaluate, no_cache, multi_label)
440
441 if output_mode == "classification":
--> 442 all_label_ids = torch.tensor([f.label_id for f in features], dtype=torch.long)
443 elif output_mode == "regression":
444 all_label_ids = torch.tensor([f.label_id for f in features], dtype=torch.float)

ValueError: too many dimensions 'str'

@ahujaravinder022
Copy link
Author

Hi
I am getting the error when I am trying to execute the code:

model.train_model(train_df)

@ThilinaRajapakse
Copy link
Owner

What is the data in train_df? Is it the minimal example code?

@ThilinaRajapakse
Copy link
Owner

This should be fixed now. There was a typo in the readme.

#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants