Created
May 8, 2017 08:46
-
-
Save rhee-airilab/42d0b9dbef0e62425ef8a77c120223ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py.orig 2017-05-08 17:02:53.971000000 +0900 | |
+++ tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py 2017-05-08 17:39:43.810067656 +0900 | |
@@ -558,9 +558,13 @@ | |
return nest.map_structure(enumerated_fn, *args, **kwargs) | |
+VRDV_MIN, VRDV_MAX = 1.0e-30, 1.0e30 # XXX clip boundary for variational_rnn_dropout | |
+ | |
+ | |
class DropoutWrapper(RNNCell): | |
"""Operator adding dropout to inputs and outputs of the given cell.""" | |
+ | |
def __init__(self, cell, input_keep_prob=1.0, output_keep_prob=1.0, | |
state_keep_prob=1.0, variational_recurrent=False, | |
input_size=None, dtype=None, seed=None): | |
@@ -685,7 +689,15 @@ | |
# 0. if [keep_prob, 1.0) and 1. if [1.0, 1.0 + keep_prob) | |
binary_tensor = math_ops.floor(random_tensor) | |
- ret = math_ops.div(value, keep_prob) * binary_tensor | |
+ | |
+ | |
+ # ret = math_ops.div(value, keep_prob) * binary_tensor # XXX FIXME/--shr overflow?? | |
+ | |
+ | |
+ value_ = clip_ops.clip_by_value(value, VRDV_MIN, VRDV_MAX) | |
+ ret = math_ops.div(value_, keep_prob) * binary_tensor | |
+ | |
+ | |
ret.set_shape(value.get_shape()) | |
return ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment