From 5cb47352cf54b287279cba8c98538c29514fb675 Mon Sep 17 00:00:00 2001 From: pkpk Date: Thu, 13 Feb 2020 18:33:38 +0800 Subject: [PATCH] Fix bug dybert (#4271) * Update README.md (#4267) * test=develop --- dygraph/bert/README.md | 2 +- dygraph/bert/run_classifier_multi_gpu.sh | 2 +- dygraph/bert/utils/init.py | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dygraph/bert/README.md b/dygraph/bert/README.md index 53e7b0e2..8ff43b5e 100644 --- a/dygraph/bert/README.md +++ b/dygraph/bert/README.md @@ -16,7 +16,7 @@ | Model | Layers | Hidden size | Heads |Parameters | | :------| :------: | :------: |:------: |:------: | -| [BERT-Base, Uncased](https://baidu-nlp.bj.bcebos.com/DYGRAPH_models%2FBERT%2Fdata.tar.gz) | 12 | 768 |12 |110M | +| [BERT-Base, Uncased](https://baidu-nlp.bj.bcebos.com/DYGRAPH_models/BERT/data.tar.gz) | 12 | 768 |12 |110M | 每个压缩包都包含了模型配置文件 `bert_config.json`、参数文件夹 `params`、动态图参数文件夹`dygraph_params` 和词汇表 `vocab.txt`; diff --git a/dygraph/bert/run_classifier_multi_gpu.sh b/dygraph/bert/run_classifier_multi_gpu.sh index 041a1091..1e6ba61f 100755 --- a/dygraph/bert/run_classifier_multi_gpu.sh +++ b/dygraph/bert/run_classifier_multi_gpu.sh @@ -4,7 +4,7 @@ BERT_BASE_PATH="./data/pretrained_models/uncased_L-12_H-768_A-12/" TASK_NAME='MNLI' DATA_PATH="./data/glue_data/MNLI/" CKPT_PATH="./data/saved_model/mnli_models" -GPU_TO_USE="0,1,2,3" +GPU_TO_USE=0,1,2,3 export CUDA_VISIBLE_DEVICES=$GPU_TO_USE diff --git a/dygraph/bert/utils/init.py b/dygraph/bert/utils/init.py index d823473d..6b69d87e 100644 --- a/dygraph/bert/utils/init.py +++ b/dygraph/bert/utils/init.py @@ -83,7 +83,13 @@ def init_pretraining_params(exe, def init_from_static_model(dir_path, cls_model, bert_config): def load_numpy_weight(file_name): - res = np.load(os.path.join(dir_path, file_name), allow_pickle=True) + if six.PY2: + res = np.load(os.path.join(dir_path, file_name), allow_pickle=True) + else: + res = np.load( + os.path.join(dir_path, file_name), + allow_pickle=True, + encoding='latin1') assert res is not None return res -- GitLab