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
4e7977f5
You need to sign in or sign up before continuing.
Commit
4e7977f5
authored
Dec 31, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove all_variables
parent
f1fdb42e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
21 deletions
+7
-21
tensorpack/callbacks/param.py
tensorpack/callbacks/param.py
+1
-6
tensorpack/models/_test.py
tensorpack/models/_test.py
+1
-1
tensorpack/models/image_sample.py
tensorpack/models/image_sample.py
+1
-1
tensorpack/tfutils/sessinit.py
tensorpack/tfutils/sessinit.py
+3
-9
tensorpack/train/base.py
tensorpack/train/base.py
+1
-4
No files found.
tensorpack/callbacks/param.py
View file @
4e7977f5
...
...
@@ -43,12 +43,7 @@ class GraphVarParam(HyperParam):
self
.
_readable_name
,
self
.
var_name
=
get_op_var_name
(
name
)
def
setup_graph
(
self
):
try
:
all_vars
=
tf
.
global_variables
()
except
:
# TODO
all_vars
=
tf
.
all_variables
()
for
v
in
all_vars
:
if
v
.
name
==
self
.
var_name
:
self
.
var
=
v
...
...
tensorpack/models/_test.py
View file @
4e7977f5
...
...
@@ -10,7 +10,7 @@ import unittest
class
TestModel
(
unittest
.
TestCase
):
def
run_variable
(
self
,
var
):
sess
=
tf
.
Session
()
sess
.
run
(
tf
.
initialize_all_variables
())
sess
.
run
(
tf
.
global_variables_initializer
())
if
isinstance
(
var
,
list
):
return
sess
.
run
(
var
)
else
:
...
...
tensorpack/models/image_sample.py
View file @
4e7977f5
...
...
@@ -151,7 +151,7 @@ if __name__ == '__main__':
mapv
=
tf
.
Variable
(
mapping
)
output
=
ImageSample
(
'sample'
,
[
imv
,
mapv
],
borderMode
=
'constant'
)
sess
=
tf
.
Session
()
sess
.
run
(
tf
.
initialize_all_variables
())
sess
.
run
(
tf
.
global_variables_initializer
())
#out = sess.run(tf.gradients(tf.reduce_sum(output), mapv))
#out = sess.run(output)
...
...
tensorpack/tfutils/sessinit.py
View file @
4e7977f5
...
...
@@ -46,7 +46,7 @@ class NewSession(SessionInit):
initializer.
"""
def
_init
(
self
,
sess
):
sess
.
run
(
tf
.
initialize_all_variables
())
sess
.
run
(
tf
.
global_variables_initializer
())
class
SaverRestore
(
SessionInit
):
"""
...
...
@@ -85,10 +85,7 @@ class SaverRestore(SessionInit):
for
dic
in
SaverRestore
.
_produce_restore_dict
(
vars_map
):
# multiple saver under same name scope would cause error:
# training/saver.py: assert restore_op.name.endswith("restore_all"), restore_op.name
try
:
saver
=
tf
.
train
.
Saver
(
var_list
=
dic
,
name
=
str
(
id
(
dic
)),
write_version
=
2
)
except
:
saver
=
tf
.
train
.
Saver
(
var_list
=
dic
,
name
=
str
(
id
(
dic
)))
saver
.
restore
(
sess
,
self
.
path
)
def
set_path
(
self
,
model_path
):
...
...
@@ -124,10 +121,7 @@ class SaverRestore(SessionInit):
:param vars_available: varaible names available in the checkpoint, for existence checking
:returns: a dict of {var_name: [var, var]} to restore
"""
try
:
vars_to_restore
=
tf
.
global_variables
()
except
AttributeError
:
vars_to_restore
=
tf
.
all_variables
()
var_dict
=
defaultdict
(
list
)
chkpt_vars_used
=
set
()
for
v
in
vars_to_restore
:
...
...
tensorpack/train/base.py
View file @
4e7977f5
...
...
@@ -119,10 +119,7 @@ class Trainer(object):
logger
.
info
(
"Initializing graph variables ..."
)
# TODO newsession + sessinit?
try
:
initop
=
tf
.
global_variables_initializer
()
except
:
initop
=
tf
.
initialize_all_variables
()
self
.
sess
.
run
(
initop
)
self
.
config
.
session_init
.
init
(
self
.
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