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
5adf1f73
You need to sign in or sign up before continuing.
Commit
5adf1f73
authored
Jan 05, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freeze get_variable
parent
b26a945e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
README.md
README.md
+1
-1
tensorpack/tfutils/varreplace.py
tensorpack/tfutils/varreplace.py
+16
-1
No files found.
README.md
View file @
5adf1f73
# tensorpack
# tensorpack
Neural Network Toolbox on TensorFlow
Neural Network Toolbox on TensorFlow
See some
[
examples
](
examples
)
to learn about the framework:
Docs & tutorials should be ready within a month.
See some
[
examples
](
examples
)
to learn about the framework:
### Vision:
### Vision:
+
[
DoReFa-Net: train binary / low-bitwidth CNN on ImageNet
](
examples/DoReFa-Net
)
+
[
DoReFa-Net: train binary / low-bitwidth CNN on ImageNet
](
examples/DoReFa-Net
)
...
...
tensorpack/tfutils/varreplace.py
View file @
5adf1f73
...
@@ -7,7 +7,9 @@ import tensorflow as tf
...
@@ -7,7 +7,9 @@ import tensorflow as tf
from
tensorflow.python.ops
import
variable_scope
from
tensorflow.python.ops
import
variable_scope
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
__all__
=
[
'replace_get_variable'
]
__all__
=
[
'replace_get_variable'
,
'freeze_get_variable'
]
_ORIG_GET_VARIABLE
=
tf
.
get_variable
@
contextmanager
@
contextmanager
...
@@ -20,3 +22,16 @@ def replace_get_variable(fn):
...
@@ -20,3 +22,16 @@ def replace_get_variable(fn):
yield
yield
tf
.
get_variable
=
old_getv
tf
.
get_variable
=
old_getv
variable_scope
.
get_variable
=
old_vars_getv
variable_scope
.
get_variable
=
old_vars_getv
def
freeze_get_variable
():
"""
Return a contextmanager, where all variables returned by
`get_variable` will have no gradients.
"""
old_get_variable
=
tf
.
get_variable
def
fn
(
name
,
shape
=
None
,
**
kwargs
):
v
=
old_get_variable
(
name
,
shape
,
**
kwargs
)
return
tf
.
stop_gradient
(
v
)
return
replace_get_variable
(
fn
)
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