简体   繁体   English

在Google Colab中运行python参数

[英]run python parameters in Google Colab

I am running a python file in Google Colab and getting an error. 我在Google Colab中运行python文件并收到错误。 I am following a bert text classification example from this link; 我正在跟踪此链接中的bert文本分类示例;

https://appliedmachinelearning.blog/2019/03/04/state-of-the-art-text-classification-using-bert-model-predict-the-happiness-hackerearth-challenge/

I followed the tutorial as described and I am at the final step to run the code snippet below in colab, 我按照说明进行了教程,最后一步是在colab中运行以下代码段,

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 know in the Colab i must run the python file like this; 我知道在Colab中我必须像这样运行python文件;

!python run_classifier.py 

But how can i set the other parameters like in the script. 但是我如何设置脚本中的其他参数。 It throughs errors. 它通过错误。 Thank you for the help. 感谢您的帮助。

You should put the \\ symbol between parameters. 您应该在参数之间放置\\符号。 For example, your code would be: 例如,您的代码将是:

!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

This worked for me in another example. 在另一个示例中,这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM