Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
f1fdb42e
You need to sign in or sign up before continuing.
Commit
f1fdb42e
authored
Dec 31, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smart --load, to handle SaverV2 format
parent
412acd12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
examples/GAN/Image2Image.py
examples/GAN/Image2Image.py
+1
-1
tensorpack/tfutils/sessinit.py
tensorpack/tfutils/sessinit.py
+12
-1
No files found.
examples/GAN/Image2Image.py
View file @
f1fdb42e
...
@@ -198,10 +198,10 @@ if __name__ == '__main__':
...
@@ -198,10 +198,10 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
gpu
:
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
assert
args
.
data
if
args
.
sample
:
if
args
.
sample
:
sample
(
args
.
data
,
args
.
load
)
sample
(
args
.
data
,
args
.
load
)
else
:
else
:
assert
args
.
data
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
...
...
tensorpack/tfutils/sessinit.py
View file @
f1fdb42e
...
@@ -58,10 +58,21 @@ class SaverRestore(SessionInit):
...
@@ -58,10 +58,21 @@ class SaverRestore(SessionInit):
:param prefix: add a `prefix/` for every variable in this checkpoint
:param prefix: add a `prefix/` for every variable in this checkpoint
"""
"""
if
os
.
path
.
basename
(
model_path
)
==
model_path
:
if
os
.
path
.
basename
(
model_path
)
==
model_path
:
model_path
=
os
.
path
.
join
(
'.'
,
model_path
)
# avoid #4921
model_path
=
os
.
path
.
join
(
'.'
,
model_path
)
# avoid #4921
and #6142
if
os
.
path
.
basename
(
model_path
)
==
'checkpoint'
:
if
os
.
path
.
basename
(
model_path
)
==
'checkpoint'
:
model_path
=
tf
.
train
.
latest_checkpoint
(
os
.
path
.
dirname
(
model_path
))
model_path
=
tf
.
train
.
latest_checkpoint
(
os
.
path
.
dirname
(
model_path
))
# to be consistent with either v1 or v2
# to be consistent with either v1 or v2
# fix paths if provided a wrong one
new_path
=
model_path
if
'00000-of-00001'
in
model_path
:
new_path
=
model_path
.
split
(
'.data'
)[
0
]
elif
model_path
.
endswith
(
'.index'
):
new_path
=
model_path
.
split
(
'.index'
)[
0
]
if
new_path
!=
model_path
:
logger
.
warn
(
"[SaverRestore] {} is corrected to {} when restoring the model."
.
format
(
model_path
,
new_path
))
model_path
=
new_path
assert
os
.
path
.
isfile
(
model_path
)
or
os
.
path
.
isfile
(
model_path
+
'.index'
),
model_path
assert
os
.
path
.
isfile
(
model_path
)
or
os
.
path
.
isfile
(
model_path
+
'.index'
),
model_path
self
.
set_path
(
model_path
)
self
.
set_path
(
model_path
)
self
.
prefix
=
prefix
self
.
prefix
=
prefix
...
...
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