def sparse_dropout(x, keep_prob, noise_shape):
    'Dropout for sparse tensors.'
    random_tensor = keep_prob
    random_tensor += tf.random_uniform(noise_shape)
    dropout_mask = tf.cast(tf.floor(random_tensor), dtype=tf.bool)
    pre_out = tf.sparse_retain(x, dropout_mask)
    return (pre_out * (1.0 / keep_prob))
Dropout for sparse tensors.
def sparse_dropout(x, keep_prob, noise_shape):
    
    random_tensor = keep_prob
    random_tensor += tf.random_uniform(noise_shape)
    dropout_mask = tf.cast(tf.floor(random_tensor), dtype=tf.bool)
    pre_out = tf.sparse_retain(x, dropout_mask)
    return (pre_out * (1.0 / keep_prob))