Skip to content

Instantly share code, notes, and snippets.

@vrjkmr
Created September 4, 2017 03:07
Show Gist options
  • Save vrjkmr/a3123b54f1deda24178b5cb52da328ef to your computer and use it in GitHub Desktop.
Save vrjkmr/a3123b54f1deda24178b5cb52da328ef to your computer and use it in GitHub Desktop.
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