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
2388f4b8
Commit
2388f4b8
authored
Sep 24, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify messages of regularizers.
parent
02020381
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
tensorpack/models/regularize.py
tensorpack/models/regularize.py
+17
-1
tensorpack/tfutils/tower.py
tensorpack/tfutils/tower.py
+2
-2
No files found.
tensorpack/models/regularize.py
View file @
2388f4b8
...
...
@@ -48,6 +48,8 @@ def regularize_cost(regex, func, name='regularize_cost'):
params
=
ctx
.
filter_vars_by_vs_name
(
params
)
G
=
tf
.
get_default_graph
()
to_regularize
=
[]
with
tf
.
name_scope
(
'regularize_cost'
):
costs
=
[]
for
p
in
params
:
...
...
@@ -55,9 +57,23 @@ def regularize_cost(regex, func, name='regularize_cost'):
if
re
.
search
(
regex
,
para_name
):
with
G
.
colocate_with
(
p
):
costs
.
append
(
func
(
p
))
_log_regularizer
(
para_name
)
to_regularize
.
append
(
para_name
)
if
not
costs
:
return
tf
.
constant
(
0
,
dtype
=
tf
.
float32
,
name
=
'empty_'
+
name
)
# remove tower prefix from names, and print
if
len
(
ctx
.
vs_name
):
prefix
=
ctx
.
vs_name
+
'/'
prefixlen
=
len
(
prefix
)
def
f
(
name
):
if
name
.
startswith
(
prefix
):
return
name
[
prefixlen
:]
return
name
to_regularize
=
list
(
map
(
f
,
to_regularize
))
to_print
=
', '
.
join
(
to_regularize
)
_log_regularizer
(
to_print
)
return
tf
.
add_n
(
costs
,
name
=
name
)
...
...
tensorpack/tfutils/tower.py
View file @
2388f4b8
...
...
@@ -14,11 +14,11 @@ _CurrentTowerContext = None
class
TowerContext
(
object
):
""" A context where the current model is being built in. """
def
__init__
(
self
,
tower_name
,
is_training
=
None
,
index
=
0
,
use_vs
=
False
):
def
__init__
(
self
,
tower_name
,
is_training
,
index
=
0
,
use_vs
=
False
):
"""
Args:
tower_name (str): The name scope of the tower.
is_training (bool):
if None, automatically determine from tower_name.
is_training (bool):
index (int): index of this tower, only used in training.
use_vs (bool): Open a new variable scope with this name.
"""
...
...
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