import numpy as np
def dropout(x, prob):
if prob < 0. or prob >= 1:
raise Exception("Dropout probability must be in interval [0, 1[.")
retain_prob = 1. - prob
sample = np.random.binomial(n=1, p=retain_prob, size=x.shape)
print(sample)
x *= sample
print(x)
x /= retain_prob
return x
x = np.asarray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=np.float32)
print(dropout(x, 0.4))