Skip to content

Instantly share code, notes, and snippets.

@ksivaman
Created July 13, 2019 21:02
Show Gist options
  • Save ksivaman/37bb859843e9e97500744aefb3ba2de6 to your computer and use it in GitHub Desktop.
Save ksivaman/37bb859843e9e97500744aefb3ba2de6 to your computer and use it in GitHub Desktop.
Forward pass for all the layers.
def forward_pass(train_X, params_w, params_b, layers=[4, 5, 1], activate=['R', 'S']):
num_layers = len(layers) - 1
activation_dict = {}
output_dict = {}
curr_act = train_X
for index in range(num_layers):
layer_index = index + 1
prev_act = curr_act
curr_weight = params_w["weight" + str(layer_index)]
curr_bias = params_b["bias" + str(layer_index)]
curr_act, curr_out = one_layer_forward_pass(prev_act, curr_weight, curr_bias, activate[index])
activation_dict["act" + str(index)] = prev_act
output_dict["out" + str(layer_index)] = curr_out
return curr_act, activation_dict, output_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment