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
2afe02ba
Commit
2afe02ba
authored
Jul 27, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make regularization work for REPLICATED
parent
731205ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
tensorpack/models/regularize.py
tensorpack/models/regularize.py
+6
-7
No files found.
tensorpack/models/regularize.py
View file @
2afe02ba
...
@@ -64,13 +64,12 @@ def regularize_cost_from_collection(name='regularize_cost'):
...
@@ -64,13 +64,12 @@ def regularize_cost_from_collection(name='regularize_cost'):
Returns:
Returns:
a scalar tensor, the regularization loss.
a scalar tensor, the regularization loss.
"""
"""
regulization_losses
=
set
(
tf
.
get_collection
(
tf
.
GraphKeys
.
REGULARIZATION_LOSSES
))
regularization_losses
=
set
(
tf
.
get_collection
(
tf
.
GraphKeys
.
REGULARIZATION_LOSSES
))
ctx
=
get_current_tower_context
()
if
len
(
regularization_losses
)
>
0
:
if
len
(
regulization_losses
)
>
0
:
# NOTE: this collection doesn't grow with towers.
# TODO only regularize variables in this tower?
# It is only added with variables that are newly created.
assert
not
ctx
.
has_own_variables
,
"REGULARIZATION_LOSSES collection doesn't work in replicated mode!"
logger
.
info
(
"Add REGULARIZATION_LOSSES of {} tensors on the total cost."
.
format
(
len
(
regularization_losses
)))
logger
.
info
(
"Apply REGULARIZATION_LOSSES on the total cost."
)
reg_loss
=
tf
.
add_n
(
list
(
regularization_losses
),
name
=
name
)
reg_loss
=
tf
.
add_n
(
list
(
regulization_losses
),
name
=
name
)
return
reg_loss
return
reg_loss
else
:
else
:
return
tf
.
constant
(
0
,
dtype
=
tf
.
float32
,
name
=
'empty_'
+
name
)
return
tf
.
constant
(
0
,
dtype
=
tf
.
float32
,
name
=
'empty_'
+
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