Last active
October 8, 2018 22:47
-
-
Save SkalskiP/2ecaabaed8d453ec437d1837ae8f631d to your computer and use it in GitHub Desktop.
Single layer backward propagation step
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
| def single_layer_backward_propagation(dA_curr, W_curr, b_curr, Z_curr, A_prev, activation="relu"): | |
| m = A_prev.shape[1] | |
| if activation is "relu": | |
| backward_activation_func = relu_backward | |
| elif activation is "sigmoid": | |
| backward_activation_func = sigmoid_backward | |
| else: | |
| raise Exception('Non-supported activation function') | |
| dZ_curr = backward_activation_func(dA_curr, Z_curr) | |
| dW_curr = np.dot(dZ_curr, A_prev.T) / m | |
| db_curr = np.sum(dZ_curr, axis=1, keepdims=True) / m | |
| dA_prev = np.dot(W_curr.T, dZ_curr) | |
| return dA_prev, dW_curr, db_curr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment