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
21c00af1
Commit
21c00af1
authored
Jun 01, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move variable initializer into NewSessionCreator
parent
d6258a71
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
tensorpack/tfutils/sesscreate.py
tensorpack/tfutils/sesscreate.py
+10
-1
tensorpack/train/base.py
tensorpack/train/base.py
+4
-4
No files found.
tensorpack/tfutils/sesscreate.py
View file @
21c00af1
...
...
@@ -5,9 +5,15 @@
import
tensorflow
as
tf
from
.common
import
get_default_sess_config
from
..utils
import
logger
__all__
=
[
'NewSessionCreator'
,
'ReuseSessionCreator'
,
'SessionCreatorAdapter'
]
"""
SessionCreator should return a session that is ready to use
(i.e. variables are initialized)
"""
class
NewSessionCreator
(
tf
.
train
.
SessionCreator
):
def
__init__
(
self
,
target
=
''
,
graph
=
None
,
config
=
None
):
...
...
@@ -23,7 +29,10 @@ class NewSessionCreator(tf.train.SessionCreator):
self
.
graph
=
graph
def
create_session
(
self
):
return
tf
.
Session
(
target
=
self
.
target
,
graph
=
self
.
graph
,
config
=
self
.
config
)
sess
=
tf
.
Session
(
target
=
self
.
target
,
graph
=
self
.
graph
,
config
=
self
.
config
)
sess
.
run
(
tf
.
global_variables_initializer
())
logger
.
info
(
"Global variables initialized."
)
return
sess
class
ReuseSessionCreator
(
tf
.
train
.
SessionCreator
):
...
...
tensorpack/train/base.py
View file @
21c00af1
...
...
@@ -118,17 +118,17 @@ class Trainer(object):
self
.
_callbacks
.
setup_graph
(
weakref
.
proxy
(
self
))
# create session
logger
.
info
(
"
Finalize the graph, create
the session ..."
)
logger
.
info
(
"
Creating
the session ..."
)
self
.
sess
=
self
.
config
.
session_creator
.
create_session
()
self
.
_monitored_sess
=
tf
.
train
.
MonitoredSession
(
session_creator
=
ReuseSessionCreator
(
self
.
sess
),
hooks
=
None
)
logger
.
info
(
"Initializing the session ..."
)
# init session
init_op
=
tf
.
global_variables_initializer
()
self
.
sess
.
run
(
init_op
)
logger
.
info
(
"Graph variables initialized."
)
self
.
config
.
session_init
.
init
(
self
.
sess
)
self
.
sess
.
graph
.
finalize
()
logger
.
info
(
"Graph Finalized."
)
hooks
=
self
.
_callbacks
.
get_hooks
()
self
.
hooked_sess
=
HookedSession
(
self
.
sess
,
hooks
)
...
...
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