marbert icon indicating copy to clipboard operation
marbert copied to clipboard

Error when running step (9) in fine_tuning function!

Open abdelrahmaan opened this issue 3 years ago • 7 comments

Get this error RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)

abdelrahmaan avatar Jan 03 '22 14:01 abdelrahmaan

Hi @abdelrahmaan

Please provide the full error.

elmadany avatar Jan 03 '22 19:01 elmadany

Hi @elmadany Here you are. Screen Shot 2022-01-03 at 9 53 31 PM

[INFO] step (9) start fine_tuning Epoch: 0%| | 0/5 [00:00<?, ?it/s]

RuntimeError Traceback (most recent call last) in () ----> 1 report_df = fine_tuning(config)

10 frames /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse) 2042 # remove once script supports set_grad_enabled 2043 no_grad_embedding_renorm(weight, input, max_norm, norm_type) -> 2044 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) 2045 2046

RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)

abdelrahmaan avatar Jan 03 '22 19:01 abdelrahmaan

This error seems due to the torch version and the training code not being updated. I recommend using the Huggingface trainer. These an examples,
https://github.com/huggingface/transformers/tree/master/notebooks First, select the trainer code based on your task. Then use "UBC-NLP/MARBERT" as the model name. I hope these will help you

elmadany avatar Jan 03 '22 20:01 elmadany

I get the same error!! @abdelrahmaan did you find a solution?

nboudad avatar Mar 09 '22 10:03 nboudad

I did MARABERT by k-train Try to use it.

abdelrahmaan avatar Mar 09 '22 10:03 abdelrahmaan

Thanks @abdelrahmaan For me, I fixed the issue using: !pip install GPUtil pytorch_pretrained_bert transformers==4.12.2 sentencepiece==0.1.96

nboudad avatar Mar 10 '22 08:03 nboudad

Hello @elmadany Can you please just tell me how to print the classification report in this code? Actually, it is urgent manner https://colab.research.google.com/drive/1M0ls7EPUi1dwqIDh6HNfJ5y826XvcgGX?usp=sharing because I want to know the f1 score for each label

Laratomeh avatar Dec 26 '22 21:12 Laratomeh