UBC-NLP / marbert

UBC ARBERT and MARBERT Deep Bidirectional Transformers for Arabic
100 stars 15 forks source link

Error when running step (9) in fine_tuning function! #8

Open abdelrahmaan opened 2 years ago

abdelrahmaan commented 2 years ago

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)

elmadany commented 2 years ago

Hi @abdelrahmaan

Please provide the full error.

abdelrahmaan commented 2 years ago

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)
elmadany commented 2 years ago

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

nboudad commented 2 years ago

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

abdelrahmaan commented 2 years ago

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

nboudad commented 2 years ago

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

Laratomeh commented 1 year ago

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