Created
May 4, 2020 21:43
-
-
Save SkalskiP/e665b7e8617935b184d70d97ab578bb1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class FlattenLayer(Layer): | |
def __init__(self): | |
self._shape = () | |
def forward_pass(self, a_prev: np.array, training: bool) -> np.array: | |
self._shape = a_prev.shape | |
return np.ravel(a_prev).reshape(a_prev.shape[0], -1) | |
def backward_pass(self, da_curr: np.array) -> np.array: | |
return da_curr.reshape(self._shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment