-
Notifications
You must be signed in to change notification settings - Fork 0
/
deep_model.py
23 lines (23 loc) · 946 Bytes
/
deep_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from for_prop import for_activation
def deep_model(X,parameters):
"""
Takes X and parameters, respectively the data and the initialized parameters from init_param() function.
Returns AV and caches, the activation value at the end of the architecture, and the cached values of every layer.
"""
caches=[]
A=X
L=len(parameters)//2 #The floor division gives the number of layers in the network
for l in range(1,L):
A_prev=A
A,cache=for_activation(A_prev,
parameters['W'+str(l)],
parameters['b'+str(l)],
activ='relu')
caches.append(cache)
AV,cache=for_activation(A,
parameters['W'+str(L)],
parameters['b'+str(L)],
activ='sigmoid')
caches.append(cache)
assert(AV.shape==(1,X.shape[1]))
return AV,caches