Can anyone explain the difference between the different dropout styles? From the documentation, I assumed that instead of dropping some units to zero (dropout), GaussianDropout multiplies those units by some distribution. However, when testing in practice, all units are touched. The result looks more like the classic GaussianNoise.
tf.random.set_seed(0)
layer = tf.keras.layers.GaussianDropout(.05, input_shape=(2,))
data = np.arange(10).reshape(5, 2).astype(np.float32)
print(data)
outputs = layer(data, training=True)
print(outputs)
results:
[[0. 1.]
[2. 3.]
[4. 5.]
[6. 7.]
[8. 9.]]
tf.Tensor(
[[0. 1.399]
[1.771 2.533]
[4.759 3.973]
[5.562 5.94 ]
[8.882 9.891]], shape=(5, 2), dtype=float32)
edit:
Apparently, this is what I wanted all along:
def RealGaussianDropout(x, rate, stddev):
keep_prob = 1 - rate
random_tensor = tf.random.uniform(tf.shape(x))
keep_mask = tf.cast(random_tensor >= rate, tf.float32)
noised = x + K.random_normal(tf.shape(x), mean=.0, stddev=stddev)
ret = tf.multiply(x, keep_mask) + tf.multiply(noised, (1-keep_mask))
return ret
outputs = RealGaussianDropout(data,0.2,0.1)
print(outputs)