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

When loading optimizer, do not silently fail

parent 5acd244b
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,6 @@ Classifier::Classifier(const std::string & name, std::filesystem::path path, std
{
torch::load(getNN(), getBestFilename(), NeuralNetworkImpl::getDevice());
getNN()->registerEmbeddings();
getNN()->to(NeuralNetworkImpl::getDevice());
}
else if (std::filesystem::exists(getLastFilename()))
{
......@@ -93,10 +92,8 @@ Classifier::Classifier(const std::string & name, std::filesystem::path path, std
resetOptimizer();
loadOptimizer();
}
else
{
getNN()->to(NeuralNetworkImpl::getDevice());
}
getNN()->to(NeuralNetworkImpl::getDevice());
}
int Classifier::getNbParameters() const
......@@ -181,8 +178,7 @@ void Classifier::initNeuralNetwork(const std::vector<std::string> & definition,
void Classifier::loadOptimizer()
{
auto optimizerPath = std::filesystem::path(fmt::format("{}/{}_optimizer.pt", path.string(), name));
if (std::filesystem::exists(optimizerPath))
torch::load(*optimizer, optimizerPath, NeuralNetworkImpl::getDevice());
torch::load(*optimizer, optimizerPath);
}
void Classifier::saveOptimizer()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment