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
2eadc59d
Commit
2eadc59d
authored
Jan 14, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing SessionCreatorAdapter
parent
55f640f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
examples/keras/README.md
examples/keras/README.md
+2
-2
tensorpack/tfutils/sesscreate.py
tensorpack/tfutils/sesscreate.py
+23
-1
No files found.
examples/keras/README.md
View file @
2eadc59d
...
@@ -38,5 +38,5 @@ Keras does not respect variable scopes or variable
...
@@ -38,5 +38,5 @@ Keras does not respect variable scopes or variable
collections, which contradicts with tensorpack trainers.
collections, which contradicts with tensorpack trainers.
Therefore Keras support is __experimental__.
Therefore Keras support is __experimental__.
These simple examples can run within tensorpack smoothly, but note that a future
version
These simple examples can run within tensorpack smoothly, but note that a future
of Keras
may break them (unlikely, though).
version of Keras or a complicated model
may break them (unlikely, though).
tensorpack/tfutils/sesscreate.py
View file @
2eadc59d
...
@@ -8,7 +8,7 @@ from ..tfutils.common import tfv1
...
@@ -8,7 +8,7 @@ from ..tfutils.common import tfv1
from
..utils
import
logger
from
..utils
import
logger
from
.common
import
get_default_sess_config
from
.common
import
get_default_sess_config
__all__
=
[
'NewSessionCreator'
,
'ReuseSessionCreator'
]
__all__
=
[
'NewSessionCreator'
,
'ReuseSessionCreator'
,
'SessionCreatorAdapter'
]
"""
"""
A SessionCreator should:
A SessionCreator should:
...
@@ -49,6 +49,9 @@ bugs. See https://github.com/tensorpack/tensorpack/issues/497 for workarounds.")
...
@@ -49,6 +49,9 @@ bugs. See https://github.com/tensorpack/tensorpack/issues/497 for workarounds.")
class
ReuseSessionCreator
(
tfv1
.
train
.
SessionCreator
):
class
ReuseSessionCreator
(
tfv1
.
train
.
SessionCreator
):
"""
Returns an existing session.
"""
def
__init__
(
self
,
sess
):
def
__init__
(
self
,
sess
):
"""
"""
Args:
Args:
...
@@ -58,3 +61,22 @@ class ReuseSessionCreator(tfv1.train.SessionCreator):
...
@@ -58,3 +61,22 @@ class ReuseSessionCreator(tfv1.train.SessionCreator):
def
create_session
(
self
):
def
create_session
(
self
):
return
self
.
sess
return
self
.
sess
class
SessionCreatorAdapter
(
tfv1
.
train
.
SessionCreator
):
"""
Apply a function on the output of a SessionCreator. Can be used to create a debug session.
"""
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