Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
27b3ff31
Unverified
Commit
27b3ff31
authored
Nov 12, 2020
by
Julien Plu
Committed by
GitHub
Nov 12, 2020
Browse files
Try to understand and apply Sylvain's comments (#8458)
parent
0fa03498
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
1 deletion
+28
-1
examples/text-classification/run_tf_text_classification.py
examples/text-classification/run_tf_text_classification.py
+6
-0
examples/text-classification/run_xnli.py
examples/text-classification/run_xnli.py
+7
-1
examples/token-classification/run_ner.py
examples/token-classification/run_ner.py
+2
-0
examples/token-classification/run_ner_old.py
examples/token-classification/run_ner_old.py
+7
-0
examples/token-classification/run_tf_ner.py
examples/token-classification/run_tf_ner.py
+6
-0
No files found.
examples/text-classification/run_tf_text_classification.py
View file @
27b3ff31
...
@@ -21,6 +21,12 @@ from transformers import (
...
@@ -21,6 +21,12 @@ from transformers import (
TFTrainer
,
TFTrainer
,
TFTrainingArguments
,
TFTrainingArguments
,
)
)
from
transformers.utils
import
logging
as
hf_logging
hf_logging
.
set_verbosity_info
()
hf_logging
.
enable_default_handler
()
hf_logging
.
enable_explicit_format
()
def
get_tfds
(
def
get_tfds
(
...
...
examples/text-classification/run_xnli.py
View file @
27b3ff31
...
@@ -29,6 +29,7 @@ from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, Tenso
...
@@ -29,6 +29,7 @@ from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, Tenso
from
torch.utils.data.distributed
import
DistributedSampler
from
torch.utils.data.distributed
import
DistributedSampler
from
tqdm
import
tqdm
,
trange
from
tqdm
import
tqdm
,
trange
import
transformers
from
transformers
import
(
from
transformers
import
(
WEIGHTS_NAME
,
WEIGHTS_NAME
,
AdamW
,
AdamW
,
...
@@ -41,6 +42,7 @@ from transformers import glue_convert_examples_to_features as convert_examples_t
...
@@ -41,6 +42,7 @@ from transformers import glue_convert_examples_to_features as convert_examples_t
from
transformers
import
xnli_compute_metrics
as
compute_metrics
from
transformers
import
xnli_compute_metrics
as
compute_metrics
from
transformers
import
xnli_output_modes
as
output_modes
from
transformers
import
xnli_output_modes
as
output_modes
from
transformers
import
xnli_processors
as
processors
from
transformers
import
xnli_processors
as
processors
from
transformers.trainer_utils
import
is_main_process
try
:
try
:
...
@@ -526,7 +528,11 @@ def main():
...
@@ -526,7 +528,11 @@ def main():
bool
(
args
.
local_rank
!=
-
1
),
bool
(
args
.
local_rank
!=
-
1
),
args
.
fp16
,
args
.
fp16
,
)
)
# Set the verbosity to info of the Transformers logger (on main process only):
if
is_main_process
(
args
.
local_rank
):
transformers
.
utils
.
logging
.
set_verbosity_info
()
transformers
.
utils
.
logging
.
enable_default_handler
()
transformers
.
utils
.
logging
.
enable_explicit_format
()
# Set seed
# Set seed
set_seed
(
args
)
set_seed
(
args
)
...
...
examples/token-classification/run_ner.py
View file @
27b3ff31
...
@@ -163,6 +163,8 @@ def main():
...
@@ -163,6 +163,8 @@ def main():
# Set the verbosity to info of the Transformers logger (on main process only):
# Set the verbosity to info of the Transformers logger (on main process only):
if
is_main_process
(
training_args
.
local_rank
):
if
is_main_process
(
training_args
.
local_rank
):
transformers
.
utils
.
logging
.
set_verbosity_info
()
transformers
.
utils
.
logging
.
set_verbosity_info
()
transformers
.
utils
.
logging
.
enable_default_handler
()
transformers
.
utils
.
logging
.
enable_explicit_format
()
logger
.
info
(
"Training/evaluation parameters %s"
,
training_args
)
logger
.
info
(
"Training/evaluation parameters %s"
,
training_args
)
# Set seed before initializing model.
# Set seed before initializing model.
...
...
examples/token-classification/run_ner_old.py
View file @
27b3ff31
...
@@ -25,6 +25,7 @@ import numpy as np
...
@@ -25,6 +25,7 @@ import numpy as np
from
seqeval.metrics
import
accuracy_score
,
f1_score
,
precision_score
,
recall_score
from
seqeval.metrics
import
accuracy_score
,
f1_score
,
precision_score
,
recall_score
from
torch
import
nn
from
torch
import
nn
import
transformers
from
transformers
import
(
from
transformers
import
(
AutoConfig
,
AutoConfig
,
AutoModelForTokenClassification
,
AutoModelForTokenClassification
,
...
@@ -35,6 +36,7 @@ from transformers import (
...
@@ -35,6 +36,7 @@ from transformers import (
TrainingArguments
,
TrainingArguments
,
set_seed
,
set_seed
,
)
)
from
transformers.trainer_utils
import
is_main_process
from
utils_ner
import
Split
,
TokenClassificationDataset
,
TokenClassificationTask
from
utils_ner
import
Split
,
TokenClassificationDataset
,
TokenClassificationTask
...
@@ -139,6 +141,11 @@ def main():
...
@@ -139,6 +141,11 @@ def main():
bool
(
training_args
.
local_rank
!=
-
1
),
bool
(
training_args
.
local_rank
!=
-
1
),
training_args
.
fp16
,
training_args
.
fp16
,
)
)
# Set the verbosity to info of the Transformers logger (on main process only):
if
is_main_process
(
training_args
.
local_rank
):
transformers
.
utils
.
logging
.
set_verbosity_info
()
transformers
.
utils
.
logging
.
enable_default_handler
()
transformers
.
utils
.
logging
.
enable_explicit_format
()
logger
.
info
(
"Training/evaluation parameters %s"
,
training_args
)
logger
.
info
(
"Training/evaluation parameters %s"
,
training_args
)
# Set seed
# Set seed
...
...
examples/token-classification/run_tf_ner.py
View file @
27b3ff31
...
@@ -33,9 +33,15 @@ from transformers import (
...
@@ -33,9 +33,15 @@ from transformers import (
TFTrainer
,
TFTrainer
,
TFTrainingArguments
,
TFTrainingArguments
,
)
)
from
transformers.utils
import
logging
as
hf_logging
from
utils_ner
import
Split
,
TFTokenClassificationDataset
,
TokenClassificationTask
from
utils_ner
import
Split
,
TFTokenClassificationDataset
,
TokenClassificationTask
hf_logging
.
set_verbosity_info
()
hf_logging
.
enable_default_handler
()
hf_logging
.
enable_explicit_format
()
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
Prev
1
2
Next
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