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

RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #3 'index' in call to _th_index_select #13

Closed
meikerwang opened this issue Nov 4, 2020 · 2 comments

Comments

@meikerwang
Copy link

Hello, I read the paper and thanks a lot for the wonderful repos.
I follow the script to fine-tune the model (https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text)
And I occur the problem and there are the output

(codebert) wangz@RJZLS:~/GenLC/CodeXGLUE/Code-Text/code-to-text/code$ python run.py --do_train --do_eval --model_type roberta --model_name_or_path $pretrained_model --train_filename $train_file --dev_filename $dev_file --output_dir $output_dir --max_source_length $source_length --max_target_length $target_length --beam_size $beam_size --train_batch_size $batch_size --eval_batch_size $batch_size --learning_rate $lr --num_train_epochs $epochs
11/04/2020 23:20:44 - INFO - __main__ -   Namespace(adam_epsilon=1e-08, beam_size=10, config_name='', dev_filename='../dataset/ruby/valid.jsonl', do_eval=True, do_lower_case=False, do_test=False, do_train=True, eval_batch_size=32, eval_steps=-1, gradient_accumulation_steps=1, learning_rate=5e-05, load_model_path=None, local_rank=-1, max_grad_norm=1.0, max_source_length=256, max_steps=-1, max_target_length=128, model_name_or_path='microsoft/codebert-base', model_type='roberta', no_cuda=False, num_train_epochs=10, output_dir='model/ruby', seed=42, test_filename=None, tokenizer_name='', train_batch_size=32, train_filename='../dataset/ruby/train.jsonl', train_steps=-1, warmup_steps=0, weight_decay=0.0)
11/04/2020 23:20:44 - WARNING - __main__ -   Process rank: -1, device: cuda, n_gpu: 1, distributed training: False
11/04/2020 23:20:46 - INFO - transformers.configuration_utils -   loading configuration file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/config.json from cache at /home/wangz/.cache/torch/transformers/1b62771d5f5169b34713b0af1ab85d80e11f7b1812fbf3ee7d03a866c5f58e72.06eb31f0a63f4e8a136733ccac422f0abf9ffa87c3e61104b57e7075a704d008
11/04/2020 23:20:46 - INFO - transformers.configuration_utils -   Model config RobertaConfig {
  "architectures": [
    "RobertaModel"
  ],
  "attention_probs_dropout_prob": 0.1,
  "bos_token_id": 0,
  "eos_token_id": 2,
  "gradient_checkpointing": false,
  "hidden_act": "gelu",
  "hidden_dropout_prob": 0.1,
  "hidden_size": 768,
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "layer_norm_eps": 1e-05,
  "max_position_embeddings": 514,
  "model_type": "roberta",
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  "output_past": true,
  "pad_token_id": 1,
  "type_vocab_size": 1,
  "vocab_size": 50265
}

11/04/2020 23:20:46 - INFO - transformers.tokenization_utils_base -   Model name 'microsoft/codebert-base' not found in model shortcut name list (roberta-base, roberta-large, roberta-large-mnli, distilroberta-base, roberta-base-openai-detector, roberta-large-openai-detector). Assuming 'microsoft/codebert-base' is a path, a model identifier, or url to a directory containing tokenizer files.
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/vocab.json from cache at /home/wangz/.cache/torch/transformers/aca4dbdf4f074d4e071c2664901fec33c8aa69c35aa0101bc669ed4b44d1f6c3.6a4061e8fc00057d21d80413635a86fdcf55b6e7594ad9e25257d2f99a02f4be
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/merges.txt from cache at /home/wangz/.cache/torch/transformers/779a2f0c38ba2ff65d9a3ee23e58db9568f44a20865c412365e3dc540f01743f.70bec105b4158ed9a1747fea67a43f5dee97855c64d62b6ec3742f4cfdb5feda
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/added_tokens.json from cache at None
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/special_tokens_map.json from cache at /home/wangz/.cache/torch/transformers/5a191080da4f00859b5d3d29529f57894583e00ab07b7c940d65c33db4b25d4d.16f949018cf247a2ea7465a74ca9a292212875e5fd72f969e0807011e7f192e4
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/tokenizer_config.json from cache at /home/wangz/.cache/torch/transformers/1b4723c5fb2d933e11c399450ea233aaf33f093b5cbef3ec864624735380e490.70b5dbd5d3b9b4c9bfb3d1f6464291ff52f6a8d96358899aa3834e173b45092d
11/04/2020 23:20:53 - INFO - transformers.tokenization_utils_base -   loading file https://s3.amazonaws.com/models.huggingface.co/bert/microsoft/codebert-base/tokenizer.json from cache at None
11/04/2020 23:20:54 - INFO - transformers.modeling_utils -   loading weights file https://cdn.huggingface.co/microsoft/codebert-base/pytorch_model.bin from cache at /home/wangz/.cache/torch/transformers/0f2ecc21b21d43a029e718179cee640eb64cca32a1f2159703ea36f4a50bdd3e.96251fe4478bac0cff9de8ae3201e5847cee59aebbcafdfe6b2c361f9398b349
11/04/2020 23:20:58 - INFO - transformers.modeling_utils -   All model checkpoint weights were used when initializing RobertaModel.

11/04/2020 23:20:58 - INFO - transformers.modeling_utils -   All the weights of RobertaModel were initialized from the model checkpoint at microsoft/codebert-base.
If your task is similar to the task the model of the ckeckpoint was trained on, you can already use RobertaModel for predictions without further training.
11/04/2020 23:21:01 - INFO - __main__ -   *** Example ***
11/04/2020 23:21:01 - INFO - __main__ -   idx: 0
11/04/2020 23:21:01 - INFO - __main__ -   source_tokens: ['<s>', 'def', '_render', '_', 'body', '_(', '_context', '_,', '_options', '_)', '_if', '_options', '_.', '_key', '?', '_(', '_:', 'partial', '_)', '_[', '_render', '_', 'partial', '_(', '_context', '_,', '_options', '_)', '_]', '_else', '_Streaming', 'Template', 'R', 'end', 'erer', '_.', '_new', '_(', '_@', 'look', 'up', '_', 'context', '_)', '_.', '_render', '_(', '_context', '_,', '_options', '_)', '_end', '_end', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   source_ids: 0 9232 19930 1215 9773 36 5377 2156 1735 4839 114 1735 479 762 116 36 4832 45593 4839 646 19930 1215 45593 36 5377 2156 1735 4839 27779 1493 34245 49522 500 1397 7160 479 92 36 787 13724 658 1215 46796 4839 479 19930 36 5377 2156 1735 4839 253 253 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   source_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   target_tokens: ['<s>', 'Render', '_but', '_returns', '_a', '_valid', '_Rack', '_body', '_.', '_If', '_fibers', '_are', '_defined', '_we', '_return', '_a', '_streaming', '_body', '_that', '_renders', '_the', '_template', '_piece', '_by', '_piece', '_.', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   target_ids: 0 48440 53 2886 10 8218 34767 809 479 318 32902 32 6533 52 671 10 5230 809 14 33428 5 27663 2125 30 2125 479 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   target_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   *** Example ***
11/04/2020 23:21:01 - INFO - __main__ -   idx: 1
11/04/2020 23:21:01 - INFO - __main__ -   source_tokens: ['<s>', 'def', '_attribute', '_', 'missing', '_(', '_match', '_,', '_*', '_args', '_,', '_&', '_block', '_)', '___', 'send', '__', '_(', '_match', '_.', '_target', '_,', '_match', '_.', '_att', 'r', '_', 'name', '_,', '_args', '_,', '_block', '_)', '_end', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   source_ids: 0 9232 21643 1215 41947 36 914 2156 1009 49503 2156 359 1803 4839 27148 37785 30529 36 914 479 1002 2156 914 479 15095 338 1215 13650 2156 49503 2156 1803 4839 253 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   source_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   target_tokens: ['<s>', '+', '_attribute', '_', 'missing', '_+', '_is', '_like', '_+', '_method', '_', 'missing', '_+', '_but', '_for', '_attributes', '_.', '_When', '_+', '_method', '_', 'missing', '_+', '_is', '_called', '_we', '_check', '_to', '_see', '_if', '_there', '_is', '_a', '_matching', '_attribute', '_method', '_.', '_If', '_so', '_we', '_tell', '_+', '_attribute', '_', 'missing', '_+', '_to', '_dispatch', '_the', '_attribute', '_.', '_This', '_method', '_can', '_be', '_overloaded', '_to', '_customize', '_the', '_behavior', '_.', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   target_ids: 0 2744 21643 1215 41947 2055 16 101 2055 5448 1215 41947 2055 53 13 16763 479 520 2055 5448 1215 41947 2055 16 373 52 1649 7 192 114 89 16 10 8150 21643 5448 479 318 98 52 1137 2055 21643 1215 41947 2055 7 22903 5 21643 479 152 5448 64 28 40894 7 30447 5 3650 479 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   target_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   *** Example ***
11/04/2020 23:21:01 - INFO - __main__ -   idx: 2
11/04/2020 23:21:01 - INFO - __main__ -   source_tokens: ['<s>', 'def', '_matched', '_', 'attribute', '_', 'method', '_(', '_method', '_', 'name', '_)', '_matches', '_=', '_self', '_.', '_class', '_.', '_send', '_(', '_:', 'attribute', '_', 'method', '_', 'mat', 'chers', '_', 'match', 'ing', '_,', '_method', '_', 'name', '_)', '_matches', '_.', '_detect', '_{', '_|', '_match', '_|', '_attribute', '_', 'method', '?', '_(', '_match', '_.', '_att', 'r', '_', 'name', '_)', '_}', '_end', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   source_ids: 0 9232 9184 1215 49202 1215 45416 36 5448 1215 13650 4839 2856 5457 1403 479 1380 479 2142 36 4832 49202 1215 45416 1215 9244 7873 1215 10565 154 2156 5448 1215 13650 4839 2856 479 10933 25522 1721 914 1721 21643 1215 45416 116 36 914 479 15095 338 1215 13650 4839 35524 253 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   source_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   target_tokens: ['<s>', 'Returns', '_a', '_struct', '_representing', '_the', '_matching', '_attribute', '_method', '_.', '_The', '_struct', '_s', '_attributes', '_are', '_prefix', '_base', '_and', '_suffix', '_.', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   target_ids: 0 48826 10 29916 4561 5 8150 21643 5448 479 20 29916 579 16763 32 46622 1542 8 47503 479 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   target_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   *** Example ***
11/04/2020 23:21:01 - INFO - __main__ -   idx: 3
11/04/2020 23:21:01 - INFO - __main__ -   source_tokens: ['<s>', 'def', '_dem', 'od', 'ul', 'ize', '_(', '_path', '_)', '_path', '_=', '_path', '_.', '_to', '_', 's', '_if', '_i', '_=', '_path', '_.', '_r', 'index', '_(', '_"', '::', '"', '_)', '_path', '_[', '_(', '_i', '_+', '_2', '_)', '_..', '_-', '_1', '_]', '_else', '_path', '_end', '_end', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   source_ids: 0 9232 4410 1630 922 2072 36 2718 4839 2718 5457 2718 479 7 1215 29 114 939 5457 2718 479 910 18480 36 22 38304 113 4839 2718 646 36 939 2055 132 4839 29942 111 112 27779 1493 2718 253 253 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   source_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   target_tokens: ['<s>', 'Rem', 'oves', '_the', '_module', '_part', '_from', '_the', '_expression', '_in', '_the', '_string', '_.', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   target_ids: 0 31157 14337 5 20686 233 31 5 8151 11 5 6755 479 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   target_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   *** Example ***
11/04/2020 23:21:01 - INFO - __main__ -   idx: 4
11/04/2020 23:21:01 - INFO - __main__ -   source_tokens: ['<s>', 'def', '_const', '_', 're', 'gex', 'p', '_(', '_camel', '_', 'c', 'ased', '_', 'word', '_)', '_parts', '_=', '_camel', '_', 'c', 'ased', '_', 'word', '_.', '_split', '_(', '_"', '::', '"', '_)', '_return', '_Re', 'gex', 'p', '_.', '_escape', '_(', '_camel', '_', 'c', 'ased', '_', 'word', '_)', '_if', '_parts', '_.', '_blank', '?', '_last', '_=', '_parts', '_.', '_pop', '_parts', '_.', '_reverse', '_.', '_inject', '_(', '_last', '_)', '_do', '_|', '_acc', '_,', '_part', '_|', '_part', '_.', '_empty', '?', '_?', '_acc', '_:', '_"#', '{', 'part', '}', '(', '::', '#', '{', 'acc', '})', '?"', '_end', '_end', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   source_ids: 0 9232 10759 1215 241 45767 642 36 35579 1215 438 11835 1215 14742 4839 1667 5457 35579 1215 438 11835 1215 14742 479 3462 36 22 38304 113 4839 671 1223 45767 642 479 5111 36 35579 1215 438 11835 1215 14742 4839 114 1667 479 15818 116 94 5457 1667 479 3495 1667 479 7213 479 17951 36 94 4839 109 1721 7678 2156 233 1721 233 479 5802 116 17487 7678 4832 35290 45152 7755 24303 1640 38304 10431 45152 7904 49424 1917 253 253 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   source_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:01 - INFO - __main__ -   target_tokens: ['<s>', 'Mount', 's', '_a', '_regular', '_expression', '_returned', '_as', '_a', '_string', '_to', '_ease', '_interpol', 'ation', '_that', '_will', '_match', '_part', '_by', '_part', '_the', '_given', '_constant', '_.', '</s>']
11/04/2020 23:21:01 - INFO - __main__ -   target_ids: 0 42036 29 10 1675 8151 1835 25 10 6755 7 5136 46687 1258 14 40 914 233 30 233 5 576 5891 479 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11/04/2020 23:21:01 - INFO - __main__ -   target_mask: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11/04/2020 23:21:02 - INFO - __main__ -   ***** Running training *****
11/04/2020 23:21:02 - INFO - __main__ -     Num examples = 2000
11/04/2020 23:21:02 - INFO - __main__ -     Batch size = 32
11/04/2020 23:21:02 - INFO - __main__ -     Num epoch = 10
epoch 0 loss 8.0074: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 63/63 [01:08<00:00,  1.08s/it]
11/04/2020 23:22:10 - INFO - __main__ -   
***** Running evaluation *****
11/04/2020 23:22:10 - INFO - __main__ -     Num examples = 100
11/04/2020 23:22:10 - INFO - __main__ -     Batch size = 32
11/04/2020 23:22:11 - INFO - __main__ -     eval_ppl = 508.65501
11/04/2020 23:22:11 - INFO - __main__ -     global_step = 64
11/04/2020 23:22:11 - INFO - __main__ -     train_loss = 8.0074
11/04/2020 23:22:11 - INFO - __main__ -     ********************
11/04/2020 23:22:12 - INFO - __main__ -     Best ppl:508.65501
11/04/2020 23:22:12 - INFO - __main__ -     ********************
Traceback (most recent call last):
  File "run.py", line 518, in <module>
    main()
  File "run.py", line 434, in main
    preds = model(source_ids=source_ids,source_mask=source_mask)  
  File "/home/wangz/miniconda3/envs/codebert/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wangz/GenLC/CodeXGLUE/Code-Text/code-to-text/code/model.py", line 97, in forward
    input_ids.data.copy_(input_ids.data.index_select(0, beam.getCurrentOrigin()))
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #3 'index' in call to _th_index_select
@marnaoty
Copy link

marnaoty commented Nov 5, 2020

I think this bug is due to changes in recent pytorch versions.

I think the buggy line is:
prevK = bestScoresId / numWords
inside the beam advance function.

I think the original implementation was seeking an integer division here in this line, but pytorch no longer consider this as an integer division. Probably you can solve this by using // instead.

I hope we can get an answer from the original contributers.

@meikerwang
Copy link
Author

meikerwang commented Nov 5, 2020

@marnaoty Thank you for your reply and these details~
I modify the buggy line by using integer division "//" to replace float division "/" and run the code successfully
Also can use floor_divide instead of true_divide

I think this bug is due to changes in recent pytorch versions.

I think the buggy line is:
prevK = bestScoresId / numWords
inside the beam advance function.

I think the original implementation was seeking an integer division here in this line, but pytorch no longer consider this as an integer division. Probably you can solve this by using // instead.

I hope we can get an answer from the original contributers.

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