Skip to content

Instantly share code, notes, and snippets.

@SkalskiP
Last active May 23, 2020 17:01
Show Gist options
  • Save SkalskiP/b943b568976fc4bbb47ed024ce02a071 to your computer and use it in GitHub Desktop.
Save SkalskiP/b943b568976fc4bbb47ed024ce02a071 to your computer and use it in GitHub Desktop.
Flatten layer
def forward_pass(self, a_prev: np.array) -> 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