Skip to content
Snippets Groups Projects
Commit 9fb78420 authored by Franck Dary's avatar Franck Dary
Browse files

Print time during training

parent 7e7d8d52
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,8 @@ bool isSeparator(utf8char c); ...@@ -54,6 +54,8 @@ bool isSeparator(utf8char c);
bool isIllegal(utf8char c); bool isIllegal(utf8char c);
std::string getTime();
template <typename T> template <typename T>
bool isEmpty(const std::vector<T> & s) bool isEmpty(const std::vector<T> & s)
{ {
......
...@@ -186,3 +186,14 @@ std::vector<std::filesystem::path> util::findFilesByExtension(std::filesystem::p ...@@ -186,3 +186,14 @@ std::vector<std::filesystem::path> util::findFilesByExtension(std::filesystem::p
return files; return files;
} }
std::string util::getTime()
{
std::time_t rawtime;
char buffer[80];
std::time(&rawtime);
std::strftime(buffer, sizeof(buffer), "%H:%M:%S", std::localtime(&rawtime));
return std::string(buffer);
}
...@@ -92,7 +92,7 @@ int MacaonTrain::main() ...@@ -92,7 +92,7 @@ int MacaonTrain::main()
bool printAdvancement = !debug && variables.count("silent") == 0 ? true : false; bool printAdvancement = !debug && variables.count("silent") == 0 ? true : false;
bool computeDevScore = variables.count("devScore") == 0 ? false : true; bool computeDevScore = variables.count("devScore") == 0 ? false : true;
fmt::print(stderr, "Training using device : {}\n", NeuralNetworkImpl::device.str()); fmt::print(stderr, "[{}] Training using device : {}\n", util::getTime(), NeuralNetworkImpl::device.str());
try try
{ {
...@@ -159,10 +159,9 @@ int MacaonTrain::main() ...@@ -159,10 +159,9 @@ int MacaonTrain::main()
bestDevScore = devScoreMean; bestDevScore = devScoreMean;
machine.save(); machine.save();
} }
if (debug) if (!debug)
fmt::print(stderr, "Epoch {:^5} loss = {:6.1f} dev = {} {:5}\n", fmt::format("{}/{}", i+1, nbEpoch), loss, devScoresStr, saved ? "SAVED" : ""); fmt::print(stderr, "\r{:80}\r", "");
else fmt::print(stderr, "[{}] Epoch {:^5} loss = {:6.1f} dev = {} {:5}\n", util::getTime(), fmt::format("{}/{}", i+1, nbEpoch), loss, devScoresStr, saved ? "SAVED" : "");
fmt::print(stderr, "\r{:80}\rEpoch {:^5} loss = {:6.1f} dev = {} {:5}\n", " ", fmt::format("{}/{}", i+1, nbEpoch), loss, devScoresStr, saved ? "SAVED" : "");
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment