Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#21 from wawltor/add_flag_eval_lac
Browse files Browse the repository at this point in the history
add the do_eval for the lac model train.
  • Loading branch information
ZeyuChen authored Feb 19, 2021
2 parents 5c768e3 + 1fc8727 commit 5b35fb9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/lexical_analysis/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from paddlenlp.data import Pad, Tuple, Stack
from paddlenlp.layers.crf import LinearChainCrfLoss, ViterbiDecoder
from paddlenlp.metrics import ChunkEvaluator
import distutils.util

# yapf: disable
parser = argparse.ArgumentParser(__doc__)
Expand All @@ -39,6 +40,7 @@
parser.add_argument("--emb_dim", type=int, default=128, help="The dimension in which a word is embedded.")
parser.add_argument("--hidden_size", type=int, default=128, help="The number of hidden nodes in the GRU layer.")
parser.add_argument("--verbose", type=ast.literal_eval, default=128, help="Print reader and training time in details.")
parser.add_argument("--do_eval", type=distutils.util.strtobool, default=True, help="To evaluate the model if True.")
# yapf: enable


Expand Down Expand Up @@ -97,7 +99,7 @@ def train(args):
callbacks = paddle.callbacks.ProgBarLogger(
log_freq=10, verbose=3) if args.verbose else None
model.fit(train_data=train_loader,
eval_data=test_loader,
eval_data=test_loader if args.do_eval else None,
batch_size=args.batch_size,
epochs=args.epochs,
eval_freq=1,
Expand Down

0 comments on commit 5b35fb9

Please sign in to comment.