【问题标题】:run python parameters in Google Colab在 Google Colab 中运行 python 参数
【发布时间】:2020-03-20 15:00:49
【问题描述】:

我在 Google Colab 中运行 python 文件并收到错误消息。我正在关注此链接中的一个 BERT 文本分类示例;

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

我按照描述的教程进行操作,并在最后一步在 colab 中运行下面的代码 sn-p,

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

我知道在 Colab 中我必须像这样运行 python 文件;

!python run_classifier.py 

但是我如何设置脚本中的其他参数。它通过错误。谢谢你的帮助。

【问题讨论】:

    标签: python python-3.x google-colaboratory bert-language-model


    【解决方案1】:

    您应该在参数之间放置\ 符号。例如,您的代码是:

    !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
    

    这在另一个例子中对我有用。

    【讨论】:

      猜你喜欢
      • 2018-08-31
      • 2018-11-01
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 2021-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多