Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Edit the backpropagation functions in cnn_model
Browse files Browse the repository at this point in the history
  • Loading branch information
frankxwang committed Nov 10, 2017
1 parent 35f392c commit 6b9b1b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions cnn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def back_relu(layer, deriv):
return np.multiply(layer, deriv)


# TODO get the backpropagation for pooling to work
def back_pool(layer, next_layer, deriv, size, stride=None):
if stride is None:
stride = size
Expand All @@ -82,8 +81,6 @@ def back_pool(layer, next_layer, deriv, size, stride=None):

def back_conv(layer, deriv, size, stride=[1, 1]):
derivW = np.resize(deriv, (len(deriv), len(deriv[0]) * len(deriv[0][0])))
print(deriv.shape)
print(derivW.shape)
dw = np.zeros((len(layer), len(deriv), size[0] * size[1]))
for i in range(len(layer)):
for j in range(len(deriv)):
Expand Down
4 changes: 2 additions & 2 deletions testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

layer = np.random.random_integers(-10, 10, size=(1, 100, 100))
filter_size = [2, 3]
stride = [2, 3]
stride = [1, 1]
# first dim is the current layer size, second dim is the next layer size, and third dim is the total filter size
filters = [np.random.random_integers(-5, 5, size=(3, 2, 6)), np.random.random_integers(-5, 5, size=(2, 5, 6))]

Expand All @@ -17,7 +17,7 @@

dm2 = back_relu(m2, 1)
dc2 = back_pool(c2, m2, dm2, [2, 2])
dr1 = back_conv(r1, dc2, filter_size, stride)
dr1 = back_conv(r1, dc2, filter_size, stride=stride)

print(dr1)
'''
Expand Down

0 comments on commit 6b9b1b3

Please sign in to comment.