Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
diluosixu
bert
提交
98268e3f
B
bert
项目概览
diluosixu
/
bert
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
bert
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
98268e3f
编写于
11月 06, 2018
作者:
A
Abhishek Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename inference mode inputs from predict to test
上级
41d6111d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
README.md
README.md
+2
-2
run_classifier.py
run_classifier.py
+11
-11
未找到文件。
README.md
浏览文件 @
98268e3f
...
...
@@ -308,8 +308,8 @@ that it's running on something other than a Cloud TPU, which includes a GPU.
#### Prediction from classifier
Once you have trained your classifier you can use it in inference mode by using the --do_predict=true command.
You need to have a file named
predic
t.tsv in the input folder.
Output will be created in file called
predic
t_results.tsv in the output folder.
You need to have a file named
tes
t.tsv in the input folder.
Output will be created in file called
tes
t_results.tsv in the output folder.
Each line will contain output for each sample, columns are the class probabilities.
```
shell
export
BERT_BASE_DIR
=
/path/to/bert/uncased_L-12_H-768_A-12
...
...
run_classifier.py
浏览文件 @
98268e3f
...
...
@@ -71,7 +71,7 @@ flags.DEFINE_bool("do_train", False, "Whether to run training.")
flags
.
DEFINE_bool
(
"do_eval"
,
False
,
"Whether to run eval on the dev set."
)
flags
.
DEFINE_bool
(
"do_predict"
,
False
,
"Whether to run the model in inference mode on
predic
t set."
)
flags
.
DEFINE_bool
(
"do_predict"
,
False
,
"Whether to run the model in inference mode on
the tes
t set."
)
flags
.
DEFINE_integer
(
"train_batch_size"
,
32
,
"Total batch size for training."
)
...
...
@@ -164,7 +164,7 @@ class DataProcessor(object):
"""Gets a collection of `InputExample`s for the dev set."""
raise
NotImplementedError
()
def
get_
predic
t_examples
(
self
,
data_dir
):
def
get_
tes
t_examples
(
self
,
data_dir
):
"""Gets a collection of `InputExample`s for prediction."""
raise
NotImplementedError
()
...
...
@@ -245,11 +245,11 @@ class MnliProcessor(DataProcessor):
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"dev_matched.tsv"
)),
"dev_matched"
)
def
get_
predic
t_examples
(
self
,
data_dir
):
def
get_
tes
t_examples
(
self
,
data_dir
):
"""See base class."""
return
self
.
_create_examples
(
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
predict
.tsv"
)),
"
predic
t"
)
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
test_matched
.tsv"
)),
"
tes
t"
)
def
get_labels
(
self
):
"""See base class."""
...
...
@@ -283,10 +283,10 @@ class MrpcProcessor(DataProcessor):
return
self
.
_create_examples
(
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"dev.tsv"
)),
"dev"
)
def
get_
predic
t_examples
(
self
,
data_dir
):
def
get_
tes
t_examples
(
self
,
data_dir
):
"""See base class."""
return
self
.
_create_examples
(
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
predict.tsv"
)),
"predic
t"
)
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
test.tsv"
)),
"tes
t"
)
def
get_labels
(
self
):
"""See base class."""
...
...
@@ -320,10 +320,10 @@ class ColaProcessor(DataProcessor):
return
self
.
_create_examples
(
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"dev.tsv"
)),
"dev"
)
def
get_
predic
t_examples
(
self
,
data_dir
):
def
get_
tes
t_examples
(
self
,
data_dir
):
"""See base class."""
return
self
.
_create_examples
(
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
predict.tsv"
)),
"predic
t"
)
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"
test.tsv"
)),
"tes
t"
)
def
get_labels
(
self
):
"""See base class."""
...
...
@@ -772,7 +772,7 @@ def main(_):
tf
.
logging
.
info
(
" %s = %s"
,
key
,
str
(
result
[
key
]))
writer
.
write
(
"%s = %s
\n
"
%
(
key
,
str
(
result
[
key
])))
if
FLAGS
.
do_predict
:
predict_examples
=
processor
.
get_
predic
t_examples
(
FLAGS
.
data_dir
)
predict_examples
=
processor
.
get_
tes
t_examples
(
FLAGS
.
data_dir
)
predict_file
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
"predict.tf_record"
)
convert_examples_to_features
(
predict_examples
,
label_list
,
FLAGS
.
max_seq_length
,
tokenizer
,
predict_file
)
...
...
@@ -795,7 +795,7 @@ def main(_):
result
=
estimator
.
predict
(
input_fn
=
predict_input_fn
)
output_predict_file
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
"
predic
t_results.tsv"
)
output_predict_file
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
"
tes
t_results.tsv"
)
with
tf
.
gfile
.
GFile
(
output_predict_file
,
"w"
)
as
writer
:
tf
.
logging
.
info
(
"***** Predict results *****"
)
for
prediction
in
result
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录