mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Fix loggers
This commit is contained in:
parent
4fccd2ceaf
commit
b305f2ff5a
|
@ -29,8 +29,8 @@ def console_logger(progress_bar: bool = False):
|
|||
table_header = [col.upper() for col in table_header]
|
||||
table_widths = [3, 6] + loss_widths + score_widths + [6]
|
||||
table_aligns = ["r" for _ in table_widths]
|
||||
stdout.write(msg.row(table_header, widths=table_widths))
|
||||
stdout.write(msg.row(["-" * width for width in table_widths]))
|
||||
stdout.write(msg.row(table_header, widths=table_widths) + "\n")
|
||||
stdout.write(msg.row(["-" * width for width in table_widths]) + "\n")
|
||||
progress = None
|
||||
|
||||
def log_step(info: Optional[Dict[str, Any]]) -> None:
|
||||
|
@ -75,7 +75,9 @@ def console_logger(progress_bar: bool = False):
|
|||
)
|
||||
if progress is not None:
|
||||
progress.close()
|
||||
stdout.write(msg.row(data, widths=table_widths, aligns=table_aligns))
|
||||
stdout.write(
|
||||
msg.row(data, widths=table_widths, aligns=table_aligns) + "\n"
|
||||
)
|
||||
if progress_bar:
|
||||
# Set disable=None, so that it disables on non-TTY
|
||||
progress = tqdm.tqdm(
|
||||
|
|
|
@ -69,10 +69,10 @@ def train(
|
|||
eval_frequency=T["eval_frequency"],
|
||||
exclude=frozen_components,
|
||||
)
|
||||
stdout.write(msg.info(f"Pipeline: {nlp.pipe_names}"))
|
||||
stdout.write(msg.info(f"Pipeline: {nlp.pipe_names}") + "\n")
|
||||
if frozen_components:
|
||||
stdout.write(msg.info(f"Frozen components: {frozen_components}"))
|
||||
stdout.write(msg.info(f"Initial learn rate: {optimizer.learn_rate}"))
|
||||
stdout.write(msg.info(f"Frozen components: {frozen_components}") + "\n")
|
||||
stdout.write(msg.info(f"Initial learn rate: {optimizer.learn_rate}") + "\n")
|
||||
with nlp.select_pipes(disable=frozen_components):
|
||||
log_step, finalize_logger = train_logger(nlp, stdout, stderr)
|
||||
try:
|
||||
|
@ -93,7 +93,7 @@ def train(
|
|||
msg.warn(
|
||||
f"Aborting and saving the final best model. "
|
||||
f"Encountered exception: {str(e)}"
|
||||
)
|
||||
) + "\n"
|
||||
)
|
||||
raise e
|
||||
finally:
|
||||
|
@ -106,7 +106,9 @@ def train(
|
|||
else:
|
||||
nlp.to_disk(final_model_path)
|
||||
# This will only run if we don't hit an error
|
||||
stdout.write(msg.good("Saved pipeline to output directory", final_model_path))
|
||||
stdout.write(
|
||||
msg.good("Saved pipeline to output directory", final_model_path) + "\n"
|
||||
)
|
||||
|
||||
|
||||
def train_while_improving(
|
||||
|
|
Loading…
Reference in New Issue
Block a user