Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Franck Dary
macaon
Commits
1795a1b3
Commit
1795a1b3
authored
Mar 21, 2021
by
Franck Dary
Browse files
When loading optimizer, do not silently fail
parent
5acd244b
Changes
1
Hide whitespace changes
Inline
Side-by-side
reading_machine/src/Classifier.cpp
View file @
1795a1b3
...
...
@@ -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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment