run_classifier.py: TypeError: __init__() got an unexpected keyword argument 'cache_dir'
Author: VarnithChordia
Pull request: no

python3 run_classifier.py 
--task_name MRPC 
--do_train 
--do_eval 
--do_lower_case 
--data_dir $GLUE_DIR/MRPC/ 
--bert_model bert-base-uncased 
--max_seq_length 128 
--train_batch_size 32 
--learning_rate 2e-5 
--num_train_epochs 3.0 
--output_dir /tmp/mrpc_outputunexpected
 

02/25/2019 15:50:51 - INFO - __main__ -   device: cuda n_gpu: 10, distributed training: False, 16-bits training: False

02/25/2019 15:50:51 - INFO - pytorch_pretrained_bert.file_utils -   https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt not found in cache, downloading to /tmp/tmp30rk0ety

02/25/2019 15:50:52 - INFO - pytorch_pretrained_bert.file_utils -   copying /tmp/tmp30rk0ety to cache at ..pytorch_pretrained_bert/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084

02/25/2019 15:50:52 - INFO - pytorch_pretrained_bert.file_utils -   creating metadata file for /tilde/vchordia/.pytorch_pretrained_bert/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084

02/25/2019 15:50:52 - INFO - pytorch_pretrained_bert.file_utils -   removing temp file /tmp/tmp30rk0ety

02/25/2019 15:50:52 - INFO - pytorch_pretrained_bert.tokenization -   loading vocabulary file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt from cache at ./.pytorch_pretrained_bert/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084

02/25/2019 15:50:52 - INFO - __main__ -   LOOKING AT ./glue_data/MRPC/train.tsv

02/25/2019 15:51:39 - INFO - pytorch_pretrained_bert.file_utils -   creating metadata file for ./.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6e241983c6f0.ae3cef932725ca7a30cdcb93fc6e09150a55e2a130ec7af63975a16c153ae2ba

02/25/2019 15:51:39 - INFO - pytorch_pretrained_bert.file_utils -   removing temp file /tmp/tmpacv7p93x

02/25/2019 15:51:39 - INFO - pytorch_pretrained_bert.modeling -   loading archive file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased.tar.gz from cache at ./.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6e241983c6f0.ae3cef932725ca7a30cdcb93fc6e09150a55e2a130ec7af63975a16c153ae2ba

02/25/2019 15:51:39 - INFO - pytorch_pretrained_bert.modeling -   extracting archive file ./.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6e241983c6f0.ae3cef932725ca7a30cdcb93fc6e09150a55e2a130ec7af63975a16c153ae2ba to temp dir /tmp/tmpsrcv3o3c

02/25/2019 15:51:44 - INFO - pytorch_pretrained_bert.modeling -   Model config {
  "attention_probs_dropout_prob": 0.1,
  "hidden_act": "gelu",
  "hidden_dropout_prob": 0.1,
  "hidden_size": 768,
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "max_position_embeddings": 512,
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  "type_vocab_size": 2,
  "vocab_size": 30522
}

Traceback (most recent call last):
  File "run_classifier.py", line 637, in <module>
    main()
  File "run_classifier.py", line 468, in main
    num_labels = num_labels)

  File "./anaconda3/envs/py_deep/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py", line 502, in from_pretrained
    model = cls(config, *inputs, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'cache_dir'

My issue is that I have been trying to run this test case as suggested in the readme to try test the classifier. I am not sure why the class method is not accepting cache_dir argument.

Comments:
Hi @VarnithChordia 

Were you able to fix this issue? Because I run into a similar issue.

I would appreciate any guidance on this issue. 

Thank you.


same. bump. Latest master does not handle cache_dir or mode 

@PetreanuAndi You are correct that in the latest master this issue occurs. The way I was able to fix the code was the following:

in the `run_glue.py` file, change lines 137-149:

``` 
train_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer, cache_dir=model_args.cache_dir) if training_args.do_train else None
    )
    eval_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer, mode="dev", cache_dir=model_args.cache_dir)
        if training_args.do_eval
        else None
    )

    test_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer, mode="test", cache_dir=model_args.cache_dir)
        if training_args.do_predict
        else None
    )

```
To:

```
train_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer) if training_args.do_train else None
    )
    eval_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer, mode="dev")
        if training_args.do_eval
        else None
    )
    test_dataset = (
        GlueDataset(data_args, tokenizer=tokenizer, mode="test")
        if training_args.do_predict
        else None
    )
```

Hope this helps.



Hi! That's weird, the `cache_dir` argument is available on the `GlueDataset`:

https://github.com/huggingface/transformers/blob/f45e873910e60d89511ae0193711e71c5c710468/src/transformers/data/datasets/glue.py#L58-L75

Is it possible you haven't pulled the new changes in a while? If you get an error, could you please open a new issue with all the information relative to your environment, the command you ran and the stack trace? Thanks a lot!