mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
docs: change assert to raise and some small docs (#26232)
* docs: change assert to raise and some small docs * docs: add rule and some document * fix: fix bug * fix: fix bug * chorse: revert logging * chorse: revert
This commit is contained in:
parent
375b4e0935
commit
ba47efbfe4
@ -246,13 +246,16 @@ def parse_args():
|
||||
else:
|
||||
if args.train_file is not None:
|
||||
extension = args.train_file.split(".")[-1]
|
||||
assert extension in ["csv", "json", "txt"], "`train_file` should be a csv, json or txt file."
|
||||
if extension not in ["csv", "json", "txt"]:
|
||||
raise ValueError("`train_file` should be a csv, json or txt file.")
|
||||
if args.validation_file is not None:
|
||||
extension = args.validation_file.split(".")[-1]
|
||||
assert extension in ["csv", "json", "txt"], "`validation_file` should be a csv, json or txt file."
|
||||
if extension not in ["csv", "json", "txt"]:
|
||||
raise ValueError("`validation_file` should be a csv, json or txt file.")
|
||||
|
||||
if args.push_to_hub:
|
||||
assert args.output_dir is not None, "Need an `output_dir` to create a repo when `--push_to_hub` is passed."
|
||||
if args.output_dir is None:
|
||||
raise ValueError("Need an `output_dir` to create a repo when `--push_to_hub` is passed.")
|
||||
|
||||
return args
|
||||
|
||||
|
@ -261,7 +261,8 @@ def parse_args():
|
||||
raise ValueError("`validation_file` should be a csv, json or txt file.")
|
||||
|
||||
if args.push_to_hub:
|
||||
assert args.output_dir is not None, "Need an `output_dir` to create a repo when `--push_to_hub` is passed."
|
||||
if args.output_dir is None:
|
||||
raise ValueError("Need an `output_dir` to create a repo when `--push_to_hub` is passed.")
|
||||
|
||||
return args
|
||||
|
||||
@ -694,7 +695,7 @@ def main():
|
||||
except OverflowError:
|
||||
perplexity = float("inf")
|
||||
|
||||
logger.info(f"epoch {epoch}: perplexity: {perplexity}")
|
||||
logger.info(f"epoch {epoch}: perplexity: {perplexity} eval_loss: {eval_loss}")
|
||||
|
||||
if args.with_tracking:
|
||||
accelerator.log(
|
||||
|
Loading…
Reference in New Issue
Block a user