Skip to content

Instantly share code, notes, and snippets.

@erogol
Last active January 17, 2020 21:25
Show Gist options
  • Save erogol/9eb0ab46366642887afeb78b4b8724d3 to your computer and use it in GitHub Desktop.
Save erogol/9eb0ab46366642887afeb78b4b8724d3 to your computer and use it in GitHub Desktop.
keep_p = 1- dropout_p
a = np.sqrt(target_var / (keep_p *((1-keep_p) * np.power(alpha-target_mean,2) + target_var)))
b = target_mear - a * (keep_p * target_mean + (1 - keep_p) * alpha)
def alpha_dropout(x, alpha_p=-1.758, dropout_p=0.05):
mask = np.random.rand(*x.shape) > dropout_p
x[mask] = alpha_p
output = a*x + b
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment