Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
19fa01ce
Unverified
Commit
19fa01ce
authored
Nov 30, 2020
by
Stefan Schweter
Committed by
GitHub
Nov 30, 2020
Browse files
token-classification: use is_world_process_zero instead of deprecated is_world_master() (#8828)
parent
40ecaf0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
examples/token-classification/run_ner.py
examples/token-classification/run_ner.py
+2
-2
examples/token-classification/run_ner_old.py
examples/token-classification/run_ner_old.py
+2
-2
No files found.
examples/token-classification/run_ner.py
View file @
19fa01ce
...
@@ -369,7 +369,7 @@ def main():
...
@@ -369,7 +369,7 @@ def main():
]
]
output_test_results_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_results.txt"
)
output_test_results_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_results.txt"
)
if
trainer
.
is_world_
mast
er
():
if
trainer
.
is_world_
process_z
er
o
():
with
open
(
output_test_results_file
,
"w"
)
as
writer
:
with
open
(
output_test_results_file
,
"w"
)
as
writer
:
for
key
,
value
in
metrics
.
items
():
for
key
,
value
in
metrics
.
items
():
logger
.
info
(
f
"
{
key
}
=
{
value
}
"
)
logger
.
info
(
f
"
{
key
}
=
{
value
}
"
)
...
@@ -377,7 +377,7 @@ def main():
...
@@ -377,7 +377,7 @@ def main():
# Save predictions
# Save predictions
output_test_predictions_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_predictions.txt"
)
output_test_predictions_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_predictions.txt"
)
if
trainer
.
is_world_
mast
er
():
if
trainer
.
is_world_
process_z
er
o
():
with
open
(
output_test_predictions_file
,
"w"
)
as
writer
:
with
open
(
output_test_predictions_file
,
"w"
)
as
writer
:
for
prediction
in
true_predictions
:
for
prediction
in
true_predictions
:
writer
.
write
(
" "
.
join
(
prediction
)
+
"
\n
"
)
writer
.
write
(
" "
.
join
(
prediction
)
+
"
\n
"
)
...
...
examples/token-classification/run_ner_old.py
View file @
19fa01ce
...
@@ -291,7 +291,7 @@ def main():
...
@@ -291,7 +291,7 @@ def main():
preds_list
,
_
=
align_predictions
(
predictions
,
label_ids
)
preds_list
,
_
=
align_predictions
(
predictions
,
label_ids
)
output_test_results_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_results.txt"
)
output_test_results_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_results.txt"
)
if
trainer
.
is_world_
mast
er
():
if
trainer
.
is_world_
process_z
er
o
():
with
open
(
output_test_results_file
,
"w"
)
as
writer
:
with
open
(
output_test_results_file
,
"w"
)
as
writer
:
for
key
,
value
in
metrics
.
items
():
for
key
,
value
in
metrics
.
items
():
logger
.
info
(
" %s = %s"
,
key
,
value
)
logger
.
info
(
" %s = %s"
,
key
,
value
)
...
@@ -299,7 +299,7 @@ def main():
...
@@ -299,7 +299,7 @@ def main():
# Save predictions
# Save predictions
output_test_predictions_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_predictions.txt"
)
output_test_predictions_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"test_predictions.txt"
)
if
trainer
.
is_world_
mast
er
():
if
trainer
.
is_world_
process_z
er
o
():
with
open
(
output_test_predictions_file
,
"w"
)
as
writer
:
with
open
(
output_test_predictions_file
,
"w"
)
as
writer
:
with
open
(
os
.
path
.
join
(
data_args
.
data_dir
,
"test.txt"
),
"r"
)
as
f
:
with
open
(
os
.
path
.
join
(
data_args
.
data_dir
,
"test.txt"
),
"r"
)
as
f
:
token_classification_task
.
write_predictions_to_file
(
writer
,
f
,
preds_list
)
token_classification_task
.
write_predictions_to_file
(
writer
,
f
,
preds_list
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment