Skip to content

Instantly share code, notes, and snippets.

@marcopeix
Created February 26, 2019 17:38
Show Gist options
  • Save marcopeix/5de03505342d651383100f737fc90c4e to your computer and use it in GitHub Desktop.
Save marcopeix/5de03505342d651383100f737fc90c4e to your computer and use it in GitHub Desktop.
def L_model_forward(X, parameters):
caches = []
A = X
L = len(parameters) // 2 # number of layers in the neural network
for l in range(1, L):
A_prev = A
A, cache = linear_activation_forward(A_prev,
parameters['W' + str(l)],
parameters['b' + str(l)],
activation='relu')
caches.append(cache)
AL, cache = linear_activation_forward(A,
parameters['W' + str(L)],
parameters['b' + str(L)],
activation='sigmoid')
caches.append(cache)
assert(AL.shape == (1, X.shape[1]))
return AL, caches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment