Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger correction and Seq2seq base training progress reporting #81

Merged
merged 7 commits into from
Nov 16, 2023

Conversation

zsogitbe
Copy link
Contributor

No description provided.

The aims is to show how to use the callback mechanism for message logging and progress reporting.
@@ -388,6 +388,9 @@ public void Train(int maxTrainingEpoch, ICorpus<IPairBatch> trainCorpus, ICorpus
// Train one epoch over given devices. Forward part is implemented in RunForwardOnSingleDevice function in below,
// backward, weights updates and other parts are implemented in the framework. You can see them in BaseSeq2SeqFramework.cs
TrainOneEpoch(i, trainCorpus, validCorpusList, learningRate, optimizer, taskId2metrics, decodingOptions, RunForwardOnSingleDevice);

// send progress reporting in the form of a percentage value (0-100%)
Logger.WriteLine(Logger.Level.info, "", (int)(100 * (i + 1) / maxTrainingEpoch));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the progress value, we could also show prompt likes "Finished Epoch: xxx%"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us start with this simple demo and then we can add more options later.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding prompt text like this, then others could know what it is for. :)

Logger.WriteLine(Logger.Level.info, "Finished Epoch: {0}", (int)(100 * (i + 1) / maxTrainingEpoch));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but that is not possible here because then the progress value will be interpreted as formatting (params object[] args is used for formatting the message). That is the reason for why the message must be empty for progress reporting. We should explain this in the code or find a better solution later...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could create a separated method for progress reporting? such as Logger.ReportProgress(....) ? And it could report progress to listeners delegated by callback handlers ?

sb.Append(s);
else
sb.AppendFormat(s, args);
if (s != "")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.IsNullOrEmpty(String) woudl be better. It indicates whether the specified string is null or an empty string ("").

@zhongkaifu
Copy link
Owner

Thanks @zsogitbe for adding tests for logger. Leave a few comments in the code.

@@ -388,6 +388,9 @@ public void Train(int maxTrainingEpoch, ICorpus<IPairBatch> trainCorpus, ICorpus
// Train one epoch over given devices. Forward part is implemented in RunForwardOnSingleDevice function in below,
// backward, weights updates and other parts are implemented in the framework. You can see them in BaseSeq2SeqFramework.cs
TrainOneEpoch(i, trainCorpus, validCorpusList, learningRate, optimizer, taskId2metrics, decodingOptions, RunForwardOnSingleDevice);

// send progress reporting in the form of a percentage value (0-100%)
Logger.WriteLine(Logger.Level.info, "", (int)(100 * (i + 1) / maxTrainingEpoch));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding prompt text like this, then others could know what it is for. :)

Logger.WriteLine(Logger.Level.info, "Finished Epoch: {0}", (int)(100 * (i + 1) / maxTrainingEpoch));

@zhongkaifu zhongkaifu merged commit da969bb into zhongkaifu:master Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants