-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
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)); |
There was a problem hiding this comment.
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%"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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));
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 ?
AdvUtils/Logger.cs
Outdated
sb.Append(s); | ||
else | ||
sb.AppendFormat(s, args); | ||
if (s != "") |
There was a problem hiding this comment.
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 ("").
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)); |
There was a problem hiding this comment.
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));
No description provided.