def _ragged_nn_dropout_v2(x, rate, noise_shape=None, seed=None, name=None): if noise_shape is not None: raise ValueError('noise_shape is not supported yet for RaggedTensor x') with ops.name_scope(name, 'RaggedNNDropout', [x, rate]): x = ragged_tensor.convert_to_tensor_or_ragged_tensor(x, name='x') return x.with_flat_values( nn_ops.dropout_v2(x.flat_values, rate=rate, seed=seed))
def testNoDropoutFast(self): x = array_ops.zeros((5,)) y = nn_ops.dropout(x, keep_prob=1) self.assertTrue(x is y) y = nn_ops.dropout_v2(x, rate=0) self.assertTrue(x is y)
def testNoDropoutFast(self): x = array_ops.zeros((5,)) y = nn_ops.dropout(x, keep_prob=1) self.assertTrue(x is y) y = nn_ops.dropout_v2(x, rate=0) self.assertTrue(x is y)
def dropout(i, do_dropout, v): if not isinstance(do_dropout, bool) or do_dropout: return nn_ops.dropout_v2(v, rate=1. - keep_prob, seed=self._gen_seed( salt_prefix, i)) else: return v
def testInvalidRate(self): x_dim = 40 y_dim = 30 t = constant_op.constant(1.0, shape=[x_dim, y_dim], dtype=dtypes.float32) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, -1.0) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, 1.1) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, [0.0, 1.0])
def testInvalidRate(self): x_dim = 40 y_dim = 30 t = constant_op.constant(1.0, shape=[x_dim, y_dim], dtype=dtypes.float32) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, -1.0) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, 1.1) with self.assertRaises(ValueError): nn_ops.dropout_v2(t, [0.0, 1.0])