Skip to content

Instantly share code, notes, and snippets.

@shangeth
Created December 27, 2018 06:00
Show Gist options
  • Save shangeth/973abd8e2bd75fd7813f925a4ad2a213 to your computer and use it in GitHub Desktop.
Save shangeth/973abd8e2bd75fd7813f925a4ad2a213 to your computer and use it in GitHub Desktop.
def dropout(X, drop_probability):
keep_probability = 1 - drop_probability
mask = np.random.uniform(0, 1.0, X.shape) < keep_probability
if keep_probability > 0.0:
scale = (1/keep_probability)
else:
scale = 0.0
return mask * X * scale
x = np.random.randn(3,3)
dropout(x, 0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment