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
d8627d63
Commit
d8627d63
authored
Mar 16, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add SessionCreatorAdapter (#191)
parent
16103b17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
tensorpack/tfutils/sesscreate.py
tensorpack/tfutils/sesscreate.py
+17
-1
No files found.
tensorpack/tfutils/sesscreate.py
View file @
d8627d63
...
...
@@ -5,7 +5,7 @@
import
tensorflow
as
tf
__all__
=
[
'NewSessionCreator'
,
'ReuseSessionCreator'
]
__all__
=
[
'NewSessionCreator'
,
'ReuseSessionCreator'
,
'SessionCreatorAdapter'
]
class
NewSessionCreator
(
tf
.
train
.
SessionCreator
):
...
...
@@ -32,3 +32,19 @@ class ReuseSessionCreator(tf.train.SessionCreator):
def
create_session
(
self
):
return
self
.
sess
class
SessionCreatorAdapter
(
tf
.
train
.
SessionCreator
):
def
__init__
(
self
,
session_creator
,
func
):
"""
Args:
session_creator (tf.train.SessionCreator): a session creator
func (tf.Session -> tf.Session): takes a session created by
``session_creator``, and return a new session to be returned by ``self.create_session``
"""
self
.
_creator
=
session_creator
self
.
_func
=
func
def
create_session
(
self
):
sess
=
self
.
_creator
.
create_session
()
return
self
.
_func
(
sess
)
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