Created
September 4, 2017 03:07
-
-
Save vrjkmr/a3123b54f1deda24178b5cb52da328ef to your computer and use it in GitHub Desktop.
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_propagation(X, parameters): | |
''' | |
Implements the forward propagation for the model: | |
LINEAR -> RELU -> LINEAR -> RELU -> LINEAR -> SOFTMAX | |
Arguments: | |
X -- input dataset placeholder, of shape (input size, number of examples) | |
parameters -- python dictionary containing your parameters "W1", "b1", "W2", "b2", "W3", "b3" | |
the shapes are given in initialize_parameters | |
Returns: | |
Z3 -- the output of the last LINEAR unit | |
''' | |
# Retrieve parameters from dictionary | |
W1 = parameters['W1'] | |
b1 = parameters['b1'] | |
W2 = parameters['W2'] | |
b2 = parameters['b2'] | |
W3 = parameters['W3'] | |
b3 = parameters['b3'] | |
# Carry out forward propagation | |
Z1 = tf.add(tf.matmul(W1,X), b1) | |
A1 = tf.nn.relu(Z1) | |
Z2 = tf.add(tf.matmul(W2,A1), b2) | |
A2 = tf.nn.relu(Z2) | |
Z3 = tf.add(tf.matmul(W3,A2), b3) | |
return Z3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment