Code Monkey home page Code Monkey logo

Comments (7)

ThilinaRajapakse avatar ThilinaRajapakse commented on May 21, 2024

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)

from simpletransformers.

ahujaravinder022 avatar ahujaravinder022 commented on May 21, 2024

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

from simpletransformers.

ThilinaRajapakse avatar ThilinaRajapakse commented on May 21, 2024

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.

from simpletransformers.

ahujaravinder022 avatar ahujaravinder022 commented on May 21, 2024

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'

from simpletransformers.

ahujaravinder022 avatar ahujaravinder022 commented on May 21, 2024

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

model.train_model(train_df)

from simpletransformers.

ThilinaRajapakse avatar ThilinaRajapakse commented on May 21, 2024

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

from simpletransformers.

ThilinaRajapakse avatar ThilinaRajapakse commented on May 21, 2024

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

#42

from simpletransformers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.