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

Error when training the model for Task2A #8

Open
armandrotaru opened this issue Apr 2, 2019 · 2 comments
Open

Error when training the model for Task2A #8

armandrotaru opened this issue Apr 2, 2019 · 2 comments

Comments

@armandrotaru
Copy link

armandrotaru commented Apr 2, 2019

I am trying to train the neural network model for Task2A (i.e., emoji prediction in English), from SemEval2018. However, when I run the file neural_experiment.py, located in model/task2/, I get the following error message:

File "./model/task2/neural_experiment.py", line 52, in <module>
    model_training(trainer, model_config["epochs"])

  File "../..\utils\train.py", line 387, in model_training
    trainer.train()

  File "../..\logger\training.py", line 520, in train
    self.train_loader(self.loaders["train"])

  File "../..\logger\training.py", line 488, in train_loader
    sample_batched)

  File "../..\utils\train.py", line 143, in pipeline
    outputs, attentions = nn_model(inputs, lengths)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)

  File "../..\modules\nn\models.py", line 203, in forward
    representations, attentions = self.feature_extractor(x, lengths)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)

  File "../..\modules\nn\models.py", line 140, in forward
    embeddings = self.embedding(x)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)

  File "../..\modules\nn\modules.py", line 148, in forward
    embeddings = self.embedding(x)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\modules\sparse.py", line 118, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)

  File "D:\WinPython\python-3.7.2.amd64\lib\site-packages\torch\nn\functional.py", line 1454, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)

RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding)

Do you have any idea what I should do next?

@tungsontran
Copy link

tungsontran commented Sep 6, 2019

I'm also having the same issue, not just task 2 but any sub-task of task 1 and even the pretrain 2017 task. Can anyone please help on this?

@cbaziotis
Copy link
Owner

First of all, what version of pytorch do you have? The project was developed with pytorch version 0.4.0.

Judging by the error message, the problem seems to be that the list of word ids has the wrong data type. Try casting the inputs to long type in this line, ike this:

inputs = inputs.to(DEVICE).long()
labels = labels.to(DEVICE).long()
lengths = lengths.to(DEVICE).long()

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

3 participants