Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
27fb855b
M
Models
项目概览
曾经的那一瞬间
/
Models
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27fb855b
编写于
1月 18, 2022
作者:
L
Le Hou
提交者:
A. Unique TensorFlower
1月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 422638136
上级
143fd0b6
变更
44
隐藏空白更改
内联
并排
Showing
44 changed file
with
70 addition
and
72 deletion
+70
-72
official/legacy/albert/configs.py
official/legacy/albert/configs.py
+1
-1
official/legacy/bert/README.md
official/legacy/bert/README.md
+1
-1
official/legacy/bert/__init__.py
official/legacy/bert/__init__.py
+0
-0
official/legacy/bert/bert_cloud_tpu.md
official/legacy/bert/bert_cloud_tpu.md
+0
-0
official/legacy/bert/bert_models.py
official/legacy/bert/bert_models.py
+1
-1
official/legacy/bert/bert_models_test.py
official/legacy/bert/bert_models_test.py
+2
-2
official/legacy/bert/common_flags.py
official/legacy/bert/common_flags.py
+0
-0
official/legacy/bert/configs.py
official/legacy/bert/configs.py
+0
-0
official/legacy/bert/export_tfhub.py
official/legacy/bert/export_tfhub.py
+2
-2
official/legacy/bert/export_tfhub_test.py
official/legacy/bert/export_tfhub_test.py
+2
-2
official/legacy/bert/input_pipeline.py
official/legacy/bert/input_pipeline.py
+0
-0
official/legacy/bert/model_saving_utils.py
official/legacy/bert/model_saving_utils.py
+1
-2
official/legacy/bert/model_training_utils.py
official/legacy/bert/model_training_utils.py
+0
-0
official/legacy/bert/model_training_utils_test.py
official/legacy/bert/model_training_utils_test.py
+2
-2
official/legacy/bert/run_classifier.py
official/legacy/bert/run_classifier.py
+5
-5
official/legacy/bert/run_pretraining.py
official/legacy/bert/run_pretraining.py
+5
-5
official/legacy/bert/run_squad.py
official/legacy/bert/run_squad.py
+3
-3
official/legacy/bert/run_squad_helper.py
official/legacy/bert/run_squad_helper.py
+7
-7
official/legacy/bert/serving.py
official/legacy/bert/serving.py
+2
-2
official/nlp/data/classifier_data_lib.py
official/nlp/data/classifier_data_lib.py
+1
-1
official/nlp/data/classifier_data_lib_test.py
official/nlp/data/classifier_data_lib_test.py
+1
-1
official/nlp/data/create_finetuning_data.py
official/nlp/data/create_finetuning_data.py
+1
-1
official/nlp/data/create_pretraining_data.py
official/nlp/data/create_pretraining_data.py
+1
-1
official/nlp/data/create_xlnet_pretraining_data.py
official/nlp/data/create_xlnet_pretraining_data.py
+2
-2
official/nlp/data/sentence_retrieval_lib.py
official/nlp/data/sentence_retrieval_lib.py
+1
-1
official/nlp/data/squad_lib.py
official/nlp/data/squad_lib.py
+1
-1
official/nlp/data/squad_lib_sp.py
official/nlp/data/squad_lib_sp.py
+1
-1
official/nlp/data/tagging_data_lib.py
official/nlp/data/tagging_data_lib.py
+1
-1
official/nlp/data/tagging_data_lib_test.py
official/nlp/data/tagging_data_lib_test.py
+1
-1
official/nlp/tasks/dual_encoder_test.py
official/nlp/tasks/dual_encoder_test.py
+1
-1
official/nlp/tasks/question_answering.py
official/nlp/tasks/question_answering.py
+4
-4
official/nlp/tools/export_tfhub.py
official/nlp/tools/export_tfhub.py
+1
-1
official/nlp/tools/export_tfhub_lib.py
official/nlp/tools/export_tfhub_lib.py
+1
-1
official/nlp/tools/export_tfhub_lib_test.py
official/nlp/tools/export_tfhub_lib_test.py
+1
-1
official/nlp/tools/squad_evaluate_v1_1.py
official/nlp/tools/squad_evaluate_v1_1.py
+0
-0
official/nlp/tools/squad_evaluate_v2_0.py
official/nlp/tools/squad_evaluate_v2_0.py
+0
-0
official/nlp/tools/tf1_bert_checkpoint_converter_lib.py
official/nlp/tools/tf1_bert_checkpoint_converter_lib.py
+0
-0
official/nlp/tools/tf2_albert_encoder_checkpoint_converter.py
...cial/nlp/tools/tf2_albert_encoder_checkpoint_converter.py
+5
-6
official/nlp/tools/tf2_bert_encoder_checkpoint_converter.py
official/nlp/tools/tf2_bert_encoder_checkpoint_converter.py
+8
-8
official/nlp/tools/tokenization.py
official/nlp/tools/tokenization.py
+0
-0
official/nlp/tools/tokenization_test.py
official/nlp/tools/tokenization_test.py
+1
-1
official/nlp/xlnet/training_utils.py
official/nlp/xlnet/training_utils.py
+1
-1
official/projects/nhnet/raw_data_processor.py
official/projects/nhnet/raw_data_processor.py
+1
-1
official/projects/nhnet/utils.py
official/projects/nhnet/utils.py
+1
-1
未找到文件。
official/legacy/albert/configs.py
浏览文件 @
27fb855b
...
...
@@ -16,7 +16,7 @@
import
six
from
official.
nlp
.bert
import
configs
from
official.
legacy
.bert
import
configs
class
AlbertConfig
(
configs
.
BertConfig
):
...
...
official/
nlp
/bert/README.md
→
official/
legacy
/bert/README.md
浏览文件 @
27fb855b
...
...
@@ -2,7 +2,7 @@
**WARNING**
: We are on the way to deprecate most of the code in this directory.
Please see
[
this link
](
https://github.com/tensorflow/models/blob/master/official/nlp/docs/train
.md
)
[
this link
](
../g3doc/tutorials/bert_new
.md
)
for the new tutorial and use the new code in
`nlp/modeling`
. This README is
still correct for this legacy implementation.
...
...
official/
nlp
/bert/__init__.py
→
official/
legacy
/bert/__init__.py
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/bert_cloud_tpu.md
→
official/
legacy
/bert/bert_cloud_tpu.md
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/bert_models.py
→
official/
legacy
/bert/bert_models.py
浏览文件 @
27fb855b
...
...
@@ -18,8 +18,8 @@ import gin
import
tensorflow
as
tf
import
tensorflow_hub
as
hub
from
official.legacy.albert
import
configs
as
albert_configs
from
official.legacy.bert
import
configs
from
official.modeling
import
tf_utils
from
official.nlp.bert
import
configs
from
official.nlp.modeling
import
models
from
official.nlp.modeling
import
networks
...
...
official/
nlp
/bert/bert_models_test.py
→
official/
legacy
/bert/bert_models_test.py
浏览文件 @
27fb855b
...
...
@@ -14,8 +14,8 @@
import
tensorflow
as
tf
from
official.
nlp
.bert
import
bert_models
from
official.
nlp
.bert
import
configs
as
bert_configs
from
official.
legacy
.bert
import
bert_models
from
official.
legacy
.bert
import
configs
as
bert_configs
from
official.nlp.modeling
import
networks
...
...
official/
nlp
/bert/common_flags.py
→
official/
legacy
/bert/common_flags.py
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/configs.py
→
official/
legacy
/bert/configs.py
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/export_tfhub.py
→
official/
legacy
/bert/export_tfhub.py
浏览文件 @
27fb855b
...
...
@@ -25,8 +25,8 @@ from absl import app
from
absl
import
flags
from
absl
import
logging
import
tensorflow
as
tf
from
official.
nlp
.bert
import
bert_models
from
official.
nlp
.bert
import
configs
from
official.
legacy
.bert
import
bert_models
from
official.
legacy
.bert
import
configs
FLAGS
=
flags
.
FLAGS
...
...
official/
nlp
/bert/export_tfhub_test.py
→
official/
legacy
/bert/export_tfhub_test.py
浏览文件 @
27fb855b
...
...
@@ -21,8 +21,8 @@ import numpy as np
import
tensorflow
as
tf
import
tensorflow_hub
as
hub
from
official.
nlp
.bert
import
configs
from
official.
nlp
.bert
import
export_tfhub
from
official.
legacy
.bert
import
configs
from
official.
legacy
.bert
import
export_tfhub
class
ExportTfhubTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
...
...
official/
nlp
/bert/input_pipeline.py
→
official/
legacy
/bert/input_pipeline.py
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/model_saving_utils.py
→
official/
legacy
/bert/model_saving_utils.py
浏览文件 @
27fb855b
...
...
@@ -15,10 +15,9 @@
"""Utilities to save models."""
import
os
import
typing
from
absl
import
logging
import
tensorflow
as
tf
import
typing
def
export_bert_model
(
model_export_path
:
typing
.
Text
,
...
...
official/
nlp
/bert/model_training_utils.py
→
official/
legacy
/bert/model_training_utils.py
浏览文件 @
27fb855b
文件已移动
official/
nlp
/bert/model_training_utils_test.py
→
official/
legacy
/bert/model_training_utils_test.py
浏览文件 @
27fb855b
...
...
@@ -25,8 +25,8 @@ import tensorflow as tf
from
tensorflow.python.distribute
import
combinations
from
tensorflow.python.distribute
import
strategy_combinations
from
official.
nlp
.bert
import
common_flags
from
official.
nlp
.bert
import
model_training_utils
from
official.
legacy
.bert
import
common_flags
from
official.
legacy
.bert
import
model_training_utils
common_flags
.
define_common_bert_flags
()
...
...
official/
nlp
/bert/run_classifier.py
→
official/
legacy
/bert/run_classifier.py
浏览文件 @
27fb855b
...
...
@@ -26,13 +26,13 @@ from absl import logging
import
gin
import
tensorflow
as
tf
from
official.common
import
distribute_utils
from
official.legacy.bert
import
bert_models
from
official.legacy.bert
import
common_flags
from
official.legacy.bert
import
configs
as
bert_configs
from
official.legacy.bert
import
input_pipeline
from
official.legacy.bert
import
model_saving_utils
from
official.modeling
import
performance
from
official.nlp
import
optimization
from
official.nlp.bert
import
bert_models
from
official.nlp.bert
import
common_flags
from
official.nlp.bert
import
configs
as
bert_configs
from
official.nlp.bert
import
input_pipeline
from
official.nlp.bert
import
model_saving_utils
from
official.utils.misc
import
keras_utils
flags
.
DEFINE_enum
(
...
...
official/
nlp
/bert/run_pretraining.py
→
official/
legacy
/bert/run_pretraining.py
浏览文件 @
27fb855b
...
...
@@ -21,13 +21,13 @@ from absl import logging
import
gin
import
tensorflow
as
tf
from
official.common
import
distribute_utils
from
official.legacy.bert
import
bert_models
from
official.legacy.bert
import
common_flags
from
official.legacy.bert
import
configs
from
official.legacy.bert
import
input_pipeline
from
official.legacy.bert
import
model_training_utils
from
official.modeling
import
performance
from
official.nlp
import
optimization
from
official.nlp.bert
import
bert_models
from
official.nlp.bert
import
common_flags
from
official.nlp.bert
import
configs
from
official.nlp.bert
import
input_pipeline
from
official.nlp.bert
import
model_training_utils
flags
.
DEFINE_string
(
'input_files'
,
None
,
...
...
official/
nlp
/bert/run_squad.py
→
official/
legacy
/bert/run_squad.py
浏览文件 @
27fb855b
...
...
@@ -25,10 +25,10 @@ from absl import logging
import
gin
import
tensorflow
as
tf
from
official.common
import
distribute_utils
from
official.nlp.bert
import
configs
as
bert_configs
from
official.nlp.bert
import
run_squad_helper
from
official.nlp.bert
import
tokenization
from
official.legacy.bert
import
configs
as
bert_configs
from
official.legacy.bert
import
run_squad_helper
from
official.nlp.data
import
squad_lib
as
squad_lib_wp
from
official.nlp.tools
import
tokenization
from
official.utils.misc
import
keras_utils
...
...
official/
nlp
/bert/run_squad_helper.py
→
official/
legacy
/bert/run_squad_helper.py
浏览文件 @
27fb855b
...
...
@@ -21,16 +21,16 @@ import os
from
absl
import
flags
from
absl
import
logging
import
tensorflow
as
tf
from
official.legacy.bert
import
bert_models
from
official.legacy.bert
import
common_flags
from
official.legacy.bert
import
input_pipeline
from
official.legacy.bert
import
model_saving_utils
from
official.legacy.bert
import
model_training_utils
from
official.modeling
import
performance
from
official.nlp
import
optimization
from
official.nlp.bert
import
bert_models
from
official.nlp.bert
import
common_flags
from
official.nlp.bert
import
input_pipeline
from
official.nlp.bert
import
model_saving_utils
from
official.nlp.bert
import
model_training_utils
from
official.nlp.bert
import
squad_evaluate_v1_1
from
official.nlp.bert
import
squad_evaluate_v2_0
from
official.nlp.data
import
squad_lib_sp
from
official.nlp.tools
import
squad_evaluate_v1_1
from
official.nlp.tools
import
squad_evaluate_v2_0
from
official.utils.misc
import
keras_utils
...
...
official/
nlp
/bert/serving.py
→
official/
legacy
/bert/serving.py
浏览文件 @
27fb855b
...
...
@@ -18,8 +18,8 @@ from absl import app
from
absl
import
flags
import
tensorflow
as
tf
from
official.
nlp
.bert
import
bert_models
from
official.
nlp
.bert
import
configs
from
official.
legacy
.bert
import
bert_models
from
official.
legacy
.bert
import
configs
flags
.
DEFINE_integer
(
"sequence_length"
,
None
,
"Sequence length to parse the tf.Example. If "
...
...
official/nlp/data/classifier_data_lib.py
浏览文件 @
27fb855b
...
...
@@ -24,7 +24,7 @@ from absl import logging
import
tensorflow
as
tf
import
tensorflow_datasets
as
tfds
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
class
InputExample
(
object
):
...
...
official/nlp/data/classifier_data_lib_test.py
浏览文件 @
27fb855b
...
...
@@ -21,8 +21,8 @@ from absl.testing import parameterized
import
tensorflow
as
tf
import
tensorflow_datasets
as
tfds
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
classifier_data_lib
from
official.nlp.tools
import
tokenization
def
decode_record
(
record
,
name_to_features
):
...
...
official/nlp/data/create_finetuning_data.py
浏览文件 @
27fb855b
...
...
@@ -22,7 +22,6 @@ import os
from
absl
import
app
from
absl
import
flags
import
tensorflow
as
tf
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
classifier_data_lib
from
official.nlp.data
import
sentence_retrieval_lib
# word-piece tokenizer based squad_lib
...
...
@@ -30,6 +29,7 @@ from official.nlp.data import squad_lib as squad_lib_wp
# sentence-piece tokenizer based squad_lib
from
official.nlp.data
import
squad_lib_sp
from
official.nlp.data
import
tagging_data_lib
from
official.nlp.tools
import
tokenization
FLAGS
=
flags
.
FLAGS
...
...
official/nlp/data/create_pretraining_data.py
浏览文件 @
27fb855b
...
...
@@ -24,7 +24,7 @@ from absl import flags
from
absl
import
logging
import
tensorflow
as
tf
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
FLAGS
=
flags
.
FLAGS
...
...
official/nlp/data/create_xlnet_pretraining_data.py
浏览文件 @
27fb855b
...
...
@@ -14,6 +14,7 @@
"""Create LM TF examples for XLNet."""
import
dataclasses
import
json
import
math
import
os
...
...
@@ -28,11 +29,10 @@ from absl import app
from
absl
import
flags
from
absl
import
logging
import
dataclasses
import
numpy
as
np
import
tensorflow
as
tf
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
special_symbols
=
{
"<unk>"
:
0
,
...
...
official/nlp/data/sentence_retrieval_lib.py
浏览文件 @
27fb855b
...
...
@@ -17,8 +17,8 @@
import
os
from
absl
import
logging
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
classifier_data_lib
from
official.nlp.tools
import
tokenization
class
BuccProcessor
(
classifier_data_lib
.
DataProcessor
):
...
...
official/nlp/data/squad_lib.py
浏览文件 @
27fb855b
...
...
@@ -25,7 +25,7 @@ import six
from
absl
import
logging
import
tensorflow
as
tf
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
class
SquadExample
(
object
):
...
...
official/nlp/data/squad_lib_sp.py
浏览文件 @
27fb855b
...
...
@@ -28,7 +28,7 @@ from absl import logging
import
numpy
as
np
import
tensorflow
as
tf
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
class
SquadExample
(
object
):
...
...
official/nlp/data/tagging_data_lib.py
浏览文件 @
27fb855b
...
...
@@ -19,8 +19,8 @@ import os
from
absl
import
logging
import
tensorflow
as
tf
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
classifier_data_lib
from
official.nlp.tools
import
tokenization
# A negative label id for the padding label, which will not contribute
# to loss/metrics in training.
...
...
official/nlp/data/tagging_data_lib_test.py
浏览文件 @
27fb855b
...
...
@@ -19,8 +19,8 @@ import random
from
absl.testing
import
parameterized
import
tensorflow
as
tf
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
tagging_data_lib
from
official.nlp.tools
import
tokenization
def
_create_fake_file
(
filename
,
labels
,
is_test
):
...
...
official/nlp/tasks/dual_encoder_test.py
浏览文件 @
27fb855b
...
...
@@ -19,7 +19,7 @@ import os
from
absl.testing
import
parameterized
import
tensorflow
as
tf
from
official.
nlp
.bert
import
configs
from
official.
legacy
.bert
import
configs
from
official.nlp.configs
import
bert
from
official.nlp.configs
import
encoders
from
official.nlp.data
import
dual_encoder_dataloader
...
...
official/nlp/tasks/question_answering.py
浏览文件 @
27fb855b
...
...
@@ -13,13 +13,13 @@
# limitations under the License.
"""Question answering task."""
import
dataclasses
import
functools
import
json
import
os
from
typing
import
List
,
Optional
from
absl
import
logging
import
dataclasses
import
orbit
import
tensorflow
as
tf
...
...
@@ -27,15 +27,15 @@ from official.core import base_task
from
official.core
import
config_definitions
as
cfg
from
official.core
import
task_factory
from
official.modeling.hyperparams
import
base_config
from
official.nlp.bert
import
squad_evaluate_v1_1
from
official.nlp.bert
import
squad_evaluate_v2_0
from
official.nlp.bert
import
tokenization
from
official.nlp.configs
import
encoders
from
official.nlp.data
import
data_loader_factory
from
official.nlp.data
import
squad_lib
as
squad_lib_wp
from
official.nlp.data
import
squad_lib_sp
from
official.nlp.modeling
import
models
from
official.nlp.tasks
import
utils
from
official.nlp.tools
import
squad_evaluate_v1_1
from
official.nlp.tools
import
squad_evaluate_v2_0
from
official.nlp.tools
import
tokenization
@
dataclasses
.
dataclass
...
...
official/nlp/tools/export_tfhub.py
浏览文件 @
27fb855b
...
...
@@ -71,8 +71,8 @@ from absl import app
from
absl
import
flags
import
gin
from
official.legacy.bert
import
configs
from
official.modeling
import
hyperparams
from
official.nlp.bert
import
configs
from
official.nlp.configs
import
encoders
from
official.nlp.tools
import
export_tfhub_lib
...
...
official/nlp/tools/export_tfhub_lib.py
浏览文件 @
27fb855b
...
...
@@ -28,8 +28,8 @@ import tensorflow as tf
from
tensorflow.core.protobuf
import
saved_model_pb2
from
tensorflow.python.ops
import
control_flow_ops
# pylint: enable=g-direct-tensorflow-import
from
official.legacy.bert
import
configs
from
official.modeling
import
tf_utils
from
official.nlp.bert
import
configs
from
official.nlp.configs
import
encoders
from
official.nlp.modeling
import
layers
from
official.nlp.modeling
import
models
...
...
official/nlp/tools/export_tfhub_lib_test.py
浏览文件 @
27fb855b
...
...
@@ -24,8 +24,8 @@ import tensorflow_hub as hub
import
tensorflow_text
as
text
from
sentencepiece
import
SentencePieceTrainer
from
official.legacy.bert
import
configs
from
official.modeling
import
tf_utils
from
official.nlp.bert
import
configs
from
official.nlp.configs
import
encoders
from
official.nlp.modeling
import
layers
from
official.nlp.modeling
import
models
...
...
official/nlp/
bert
/squad_evaluate_v1_1.py
→
official/nlp/
tools
/squad_evaluate_v1_1.py
浏览文件 @
27fb855b
文件已移动
official/nlp/
bert
/squad_evaluate_v2_0.py
→
official/nlp/
tools
/squad_evaluate_v2_0.py
浏览文件 @
27fb855b
文件已移动
official/nlp/
bert/tf1
_checkpoint_converter_lib.py
→
official/nlp/
tools/tf1_bert
_checkpoint_converter_lib.py
浏览文件 @
27fb855b
文件已移动
official/nlp/tools/tf2_albert_encoder_checkpoint_converter.py
浏览文件 @
27fb855b
...
...
@@ -25,9 +25,9 @@ from absl import flags
import
tensorflow
as
tf
from
official.legacy.albert
import
configs
from
official.modeling
import
tf_utils
from
official.nlp.bert
import
tf1_checkpoint_converter_lib
from
official.nlp.modeling
import
models
from
official.nlp.modeling
import
networks
from
official.nlp.tools
import
tf1_bert_checkpoint_converter_lib
FLAGS
=
flags
.
FLAGS
...
...
@@ -128,12 +128,12 @@ def convert_checkpoint(bert_config, output_path, v1_checkpoint,
# Create a temporary V1 name-converted checkpoint in the output directory.
temporary_checkpoint_dir
=
os
.
path
.
join
(
output_dir
,
"temp_v1"
)
temporary_checkpoint
=
os
.
path
.
join
(
temporary_checkpoint_dir
,
"ckpt"
)
tf1_checkpoint_converter_lib
.
convert
(
tf1_
bert_
checkpoint_converter_lib
.
convert
(
checkpoint_from_path
=
v1_checkpoint
,
checkpoint_to_path
=
temporary_checkpoint
,
num_heads
=
bert_config
.
num_attention_heads
,
name_replacements
=
ALBERT_NAME_REPLACEMENTS
,
permutations
=
tf1_checkpoint_converter_lib
.
BERT_V2_PERMUTATIONS
,
permutations
=
tf1_
bert_
checkpoint_converter_lib
.
BERT_V2_PERMUTATIONS
,
exclude_patterns
=
[
"adam"
,
"Adam"
])
# Create a V2 checkpoint from the temporary checkpoint.
...
...
@@ -144,9 +144,8 @@ def convert_checkpoint(bert_config, output_path, v1_checkpoint,
else
:
raise
ValueError
(
"Unsupported converted_model: %s"
%
converted_model
)
tf1_checkpoint_converter_lib
.
create_v2_checkpoint
(
model
,
temporary_checkpoint
,
output_path
,
checkpoint_model_name
)
tf1_bert_checkpoint_converter_lib
.
create_v2_checkpoint
(
model
,
temporary_checkpoint
,
output_path
,
checkpoint_model_name
)
# Clean up the temporary checkpoint, if it exists.
try
:
...
...
official/nlp/
bert/tf2
_encoder_checkpoint_converter.py
→
official/nlp/
tools/tf2_bert
_encoder_checkpoint_converter.py
浏览文件 @
27fb855b
...
...
@@ -25,11 +25,11 @@ from absl import app
from
absl
import
flags
import
tensorflow
as
tf
from
official.legacy.bert
import
configs
from
official.modeling
import
tf_utils
from
official.nlp.bert
import
configs
from
official.nlp.bert
import
tf1_checkpoint_converter_lib
from
official.nlp.modeling
import
models
from
official.nlp.modeling
import
networks
from
official.nlp.tools
import
tf1_bert_checkpoint_converter_lib
FLAGS
=
flags
.
FLAGS
...
...
@@ -111,12 +111,13 @@ def convert_checkpoint(bert_config,
temporary_checkpoint_dir
=
os
.
path
.
join
(
output_dir
,
"temp_v1"
)
temporary_checkpoint
=
os
.
path
.
join
(
temporary_checkpoint_dir
,
"ckpt"
)
tf1_checkpoint_converter_lib
.
convert
(
tf1_
bert_
checkpoint_converter_lib
.
convert
(
checkpoint_from_path
=
v1_checkpoint
,
checkpoint_to_path
=
temporary_checkpoint
,
num_heads
=
bert_config
.
num_attention_heads
,
name_replacements
=
tf1_checkpoint_converter_lib
.
BERT_V2_NAME_REPLACEMENTS
,
permutations
=
tf1_checkpoint_converter_lib
.
BERT_V2_PERMUTATIONS
,
name_replacements
=
(
tf1_bert_checkpoint_converter_lib
.
BERT_V2_NAME_REPLACEMENTS
),
permutations
=
tf1_bert_checkpoint_converter_lib
.
BERT_V2_PERMUTATIONS
,
exclude_patterns
=
[
"adam"
,
"Adam"
])
if
converted_model
==
"encoder"
:
...
...
@@ -127,9 +128,8 @@ def convert_checkpoint(bert_config,
raise
ValueError
(
"Unsupported converted_model: %s"
%
converted_model
)
# Create a V2 checkpoint from the temporary checkpoint.
tf1_checkpoint_converter_lib
.
create_v2_checkpoint
(
model
,
temporary_checkpoint
,
output_path
,
checkpoint_model_name
)
tf1_bert_checkpoint_converter_lib
.
create_v2_checkpoint
(
model
,
temporary_checkpoint
,
output_path
,
checkpoint_model_name
)
# Clean up the temporary checkpoint, if it exists.
try
:
...
...
official/nlp/
bert
/tokenization.py
→
official/nlp/
tools
/tokenization.py
浏览文件 @
27fb855b
文件已移动
official/nlp/
bert
/tokenization_test.py
→
official/nlp/
tools
/tokenization_test.py
浏览文件 @
27fb855b
...
...
@@ -18,7 +18,7 @@ import tempfile
import
six
import
tensorflow
as
tf
from
official.nlp.
bert
import
tokenization
from
official.nlp.
tools
import
tokenization
class
TokenizationTest
(
tf
.
test
.
TestCase
):
...
...
official/nlp/xlnet/training_utils.py
浏览文件 @
27fb855b
...
...
@@ -21,7 +21,7 @@ from typing import Any, Callable, Dict, Optional, Text
from
absl
import
logging
import
tensorflow
as
tf
from
official.
nlp
.bert
import
model_training_utils
from
official.
legacy
.bert
import
model_training_utils
from
official.nlp.xlnet
import
data_utils
# pytype: disable=attribute-error
...
...
official/projects/nhnet/raw_data_processor.py
浏览文件 @
27fb855b
...
...
@@ -22,8 +22,8 @@ import urllib.parse
import
tensorflow
as
tf
from
official.nlp.bert
import
tokenization
from
official.nlp.data
import
classifier_data_lib
from
official.nlp.tools
import
tokenization
class
RawDataProcessor
(
object
):
...
...
official/projects/nhnet/utils.py
浏览文件 @
27fb855b
...
...
@@ -18,8 +18,8 @@ from typing import Optional, Text
from
absl
import
logging
import
tensorflow
as
tf
from
official.legacy.bert
import
configs
from
official.modeling.hyperparams
import
params_dict
from
official.nlp.bert
import
configs
from
official.projects.nhnet
import
configs
as
nhnet_configs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录