Created
October 24, 2018 15:39
-
-
Save muhammadgaffar/e32270c9d8001ed883a980e8e8ac58c5 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 dictionary_to_vector(parameters): | |
""" | |
Roll all our parameters dictionary into a single vector satisfying our specific required shape. | |
""" | |
keys = [] | |
count = 0 | |
params = [] | |
num_params = len(parameters)//2 | |
for l in range(1,num_params+1): | |
params = params + ["W"+str(l)] | |
params = params + ["b"+str(l)] | |
for key in params: | |
# flatten parameter | |
new_vector = np.reshape(parameters[key], (-1,1)) | |
keys = keys + [key]*new_vector.shape[0] | |
if count == 0: | |
theta = new_vector | |
else: | |
theta = np.concatenate((theta, new_vector), axis=0) | |
count = count + 1 | |
return theta, keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment