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
6b0a1a70
You need to sign in or sign up before continuing.
Commit
6b0a1a70
authored
Apr 29, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add noise_shape in Dropout layer. (fix #244)
parent
7f2c708e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
tensorpack/models/regularize.py
tensorpack/models/regularize.py
+3
-2
No files found.
tensorpack/models/regularize.py
View file @
6b0a1a70
...
...
@@ -53,7 +53,7 @@ def regularize_cost(regex, func, name='regularize_cost'):
@
layer_register
(
log_shape
=
False
,
use_scope
=
False
)
def
Dropout
(
x
,
keep_prob
=
0.5
,
is_training
=
None
):
def
Dropout
(
x
,
keep_prob
=
0.5
,
is_training
=
None
,
noise_shape
=
None
):
"""
Dropout layer as in the paper `Dropout: a Simple Way to Prevent
Neural Networks from Overfitting <http://dl.acm.org/citation.cfm?id=2670313>`_.
...
...
@@ -63,8 +63,9 @@ def Dropout(x, keep_prob=0.5, is_training=None):
when is_training=True.
is_training (bool): If None, will use the current :class:`tensorpack.tfutils.TowerContext`
to figure out.
noise_shape: same as `tf.nn.dropout`.
"""
if
is_training
is
None
:
is_training
=
get_current_tower_context
()
.
is_training
keep_prob
=
tf
.
constant
(
keep_prob
if
is_training
else
1.0
)
return
tf
.
nn
.
dropout
(
x
,
keep_prob
)
return
tf
.
nn
.
dropout
(
x
,
keep_prob
,
noise_shape
=
noise_shape
)
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