Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
f75e2dbf
Commit
f75e2dbf
authored
Apr 10, 2016
by
Davis King
Browse files
Minor code cleanup
parent
67a81c1c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
dlib/dnn/trainer.h
dlib/dnn/trainer.h
+7
-8
No files found.
dlib/dnn/trainer.h
View file @
f75e2dbf
...
@@ -315,7 +315,7 @@ namespace dlib
...
@@ -315,7 +315,7 @@ namespace dlib
time_between_syncs
=
time_between_syncs_
;
time_between_syncs
=
time_between_syncs_
;
// check if the sync file already exists, if it does we should load it.
// check if the sync file already exists, if it does we should load it.
std
::
ifstream
fin
(
filename
,
std
::
ios
::
binary
);
std
::
ifstream
fin
(
sync_
filename
,
std
::
ios
::
binary
);
if
(
fin
)
if
(
fin
)
deserialize
(
*
this
,
fin
);
deserialize
(
*
this
,
fin
);
}
}
...
@@ -571,18 +571,17 @@ namespace dlib
...
@@ -571,18 +571,17 @@ namespace dlib
if
(
std
::
chrono
::
system_clock
::
now
()
-
last_sync_time
>
time_between_syncs
||
if
(
std
::
chrono
::
system_clock
::
now
()
-
last_sync_time
>
time_between_syncs
||
do_it_now
)
do_it_now
)
{
{
// save our state to a temp file
std
::
string
tempfile
=
sync_filename
+
".tmp"
;
std
::
ofstream
fout
(
tempfile
,
std
::
ios
::
binary
);
// compact network before saving to disk.
wait_for_thread_to_pause
();
wait_for_thread_to_pause
();
// compact network before saving to disk.
this
->
net
.
clean
();
this
->
net
.
clean
();
serialize
(
*
this
,
fout
);
fout
.
close
();
// save our state to a temp file
const
std
::
string
tempfile
=
sync_filename
+
".tmp"
;
serialize
(
tempfile
)
<<
*
this
;
// Now that we know the state is safely saved to disk, delete the old sync
// Now that we know the state is safely saved to disk, delete the old sync
// file and move the .tmp file to it.
// file and move the .tmp file to it.
std
::
remove
(
sync_filename
.
c_str
());
std
::
rename
(
tempfile
.
c_str
(),
sync_filename
.
c_str
());
std
::
rename
(
tempfile
.
c_str
(),
sync_filename
.
c_str
());
last_sync_time
=
std
::
chrono
::
system_clock
::
now
();
last_sync_time
=
std
::
chrono
::
system_clock
::
now
();
...
...
Write
Preview
Markdown
is supported
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