Created
May 23, 2020 16:44
-
-
Save SkalskiP/435de1551c6c28e6cb03107ab04ab810 to your computer and use it in GitHub Desktop.
Dropout forward and backward
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forward_pass(self, a_prev: np.array, training: bool) -> np.array: | |
if training: | |
self._mask = (np.random.rand(*a_prev.shape) < self._keep_prob) | |
return self._apply_mask(a_prev, self._mask) | |
else: | |
return a_prev | |
def backward_pass(self, da_curr: np.array) -> np.array: | |
return self._apply_mask(da_curr, self._mask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment