Issue
I am currently exploring the model from this page and i am not sure how to run the below code
python run_classifier.py
--task_name=cola
--do_train=true
--do_eval=true
--do_predict=true
--data_dir=./data/
--vocab_file=./cased_L-12_H-768_A-12/vocab.txt
--bert_config_file=./cased_L-12_H-768_A-12/bert_config.json
--init_checkpoint=./cased_L-12_H-768_A-12/bert_model.ckpt
--max_seq_length=400
--train_batch_size=8
--learning_rate=2e-5
--num_train_epochs=3.0
--output_dir=./bert_output/
--do_lower_case=False
i have created a folder where i have download all the code from github. I have file run_classifier.py
in that folder.
In that same folder, I have created folders
data
and it has 3 tsv files as mentioned in the code.bert_output
and it is emptycased_L-12_H-768_A-12
and it has unzipped version of the model. It has filesbert_config.json
andbert_model.ckpt
andvocab.txt
then I went to my anaconda command prompt and went to the above folder using cd
command and
(C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder) C:\Users\nnn\Documents\GitHub\bert>python run_classifier.py task_name=cola do_train=true do_eval=true do_predict=true data_dir=./data/ vocab_file=./cased_L-12_H-768_A-12/vocab.txt bert_config_file=./cased_L-12_H-768_A-12/bert_config.json init_checkpoint=./cased_L-12_H-768_A-12/bert_model.ckpt max_seq_length=400 train_batch_size=8 learning_rate=2e-5 num_train_epochs=3.0 output_dir=./bert_output/ do_lower_case=False
Traceback (most recent call last):
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\absl\flags\_flagvalues.py", line 527, in _assert_validators
validator.verify(self)
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\absl\flags\_validators.py", line 81, in verify
raise _exceptions.ValidationError(self.message)
absl.flags._exceptions.ValidationError: Flag --data_dir must be specified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_classifier.py", line 981, in <module>
tf.app.run()
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\tensorflow\python\platform\app.py", line 119, in run
argv = flags.FLAGS(_sys.argv if argv is None else argv, known_only=True)
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\tensorflow\python\platform\flags.py", line 112, in __call__
return self.__dict__['__wrapped'].__call__(*args, **kwargs)
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\absl\flags\_flagvalues.py", line 635, in __call__
self._assert_all_validators()
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\absl\flags\_flagvalues.py", line 509, in _assert_all_validators
self._assert_validators(all_validators)
File "C:\Users\nnn\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\absl\flags\_flagvalues.py", line 530, in _assert_validators
raise _exceptions.IllegalFlagValueError('%s: %s' % (message, str(e)))
absl.flags._exceptions.IllegalFlagValueError: flag --data_dir=None: Flag --data_dir must be specified.
- How should i run it?
- can I execute from Spyder directly?
Solution
You are just missing the double dash (--
) in front of the flags:
python run_classifier.py ^
--task_name=cola ^
--do_train=true ^
--do_eval=true ^
--do_predict=true ^
--data_dir=./data/ ^
--vocab_file=./cased_L-12_H-768_A-12/vocab.txt ^
--bert_config_file=./cased_L-12_H-768_A-12/bert_config.json ^
--init_checkpoint=./cased_L-12_H-768_A-12/bert_model.ckpt ^
--max_seq_length=400 ^
--train_batch_size=8 ^
--learning_rate=2e-5 ^
--num_train_epochs=3.0 ^
--output_dir=./bert_output/ ^
--do_lower_case=False
(the character ^
is used to signal line continuation in windows prompt and this way make the display of the command neater)
It should be possible to run it in Spyder, provided that you pass the arguments when executing the script run_classifier.py
.
Answered By - user7440787
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.