Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
7e12e4f4
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
7e12e4f4
编写于
11月 20, 2019
作者:
C
Chen Chen
提交者:
A. Unique TensorFlower
11月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal Change
PiperOrigin-RevId: 281630227
上级
e16594d1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
8 deletion
+8
-8
official/nlp/bert_models.py
official/nlp/bert_models.py
+8
-8
未找到文件。
official/nlp/bert_models.py
浏览文件 @
7e12e4f4
...
@@ -374,7 +374,8 @@ def squad_model(bert_config,
...
@@ -374,7 +374,8 @@ def squad_model(bert_config,
bert_config: BertConfig, the config defines the core Bert model.
bert_config: BertConfig, the config defines the core Bert model.
max_seq_length: integer, the maximum input sequence length.
max_seq_length: integer, the maximum input sequence length.
float_type: tf.dtype, tf.float32 or tf.bfloat16.
float_type: tf.dtype, tf.float32 or tf.bfloat16.
initializer: Initializer for weights in BertSquadLogitsLayer.
initializer: Initializer for the final dense layer in the span labeler.
Defaulted to TruncatedNormal initializer.
hub_module_url: TF-Hub path/url to Bert module.
hub_module_url: TF-Hub path/url to Bert module.
use_keras_bert: Whether to use keras BERT. Note that when the above
use_keras_bert: Whether to use keras BERT. Note that when the above
'hub_module_url' is specified, 'use_keras_bert' cannot be True.
'hub_module_url' is specified, 'use_keras_bert' cannot be True.
...
@@ -389,12 +390,14 @@ def squad_model(bert_config,
...
@@ -389,12 +390,14 @@ def squad_model(bert_config,
if
hub_module_url
and
use_keras_bert
:
if
hub_module_url
and
use_keras_bert
:
raise
ValueError
(
raise
ValueError
(
'Cannot use hub_module_url and keras BERT at the same time.'
)
'Cannot use hub_module_url and keras BERT at the same time.'
)
if
initializer
is
None
:
initializer
=
tf
.
keras
.
initializers
.
TruncatedNormal
(
stddev
=
bert_config
.
initializer_range
)
if
use_keras_bert
:
if
use_keras_bert
:
bert_encoder
=
_get_transformer_encoder
(
bert_encoder
=
_get_transformer_encoder
(
bert_config
,
max_seq_length
,
bert_config
,
max_seq_length
,
float_type
)
float_type
)
return
bert_span_labeler
.
BertSpanLabeler
(
return
bert_span_labeler
.
BertSpanLabeler
(
network
=
bert_encoder
),
bert_encoder
network
=
bert_encoder
,
initializer
=
initializer
),
bert_encoder
input_word_ids
=
tf
.
keras
.
layers
.
Input
(
input_word_ids
=
tf
.
keras
.
layers
.
Input
(
shape
=
(
max_seq_length
,),
dtype
=
tf
.
int32
,
name
=
'input_word_ids'
)
shape
=
(
max_seq_length
,),
dtype
=
tf
.
int32
,
name
=
'input_word_ids'
)
...
@@ -421,9 +424,6 @@ def squad_model(bert_config,
...
@@ -421,9 +424,6 @@ def squad_model(bert_config,
# has dimensionality (batch_size, sequence_length, num_hidden).
# has dimensionality (batch_size, sequence_length, num_hidden).
sequence_output
=
core_model
.
outputs
[
1
]
sequence_output
=
core_model
.
outputs
[
1
]
if
initializer
is
None
:
initializer
=
tf
.
keras
.
initializers
.
TruncatedNormal
(
stddev
=
bert_config
.
initializer_range
)
squad_logits_layer
=
BertSquadLogitsLayer
(
squad_logits_layer
=
BertSquadLogitsLayer
(
initializer
=
initializer
,
float_type
=
float_type
,
name
=
'squad_logits'
)
initializer
=
initializer
,
float_type
=
float_type
,
name
=
'squad_logits'
)
start_logits
,
end_logits
=
squad_logits_layer
(
sequence_output
)
start_logits
,
end_logits
=
squad_logits_layer
(
sequence_output
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录