@@ -36,7 +36,7 @@ def fn(a, y):
36
36
@staticmethod
37
37
def delta (z , a , y ):
38
38
"""Return the error delta from the output layer."""
39
- return (a - y ) * sigmoid_prime_vec (z )
39
+ return (a - y ) * sigmoid_prime (z )
40
40
41
41
42
42
class CrossEntropyCost (object ):
@@ -123,7 +123,7 @@ def large_weight_initializer(self):
123
123
def feedforward (self , a ):
124
124
"""Return the output of the network if ``a`` is input."""
125
125
for b , w in zip (self .biases , self .weights ):
126
- a = sigmoid_vec (np .dot (w , a )+ b )
126
+ a = sigmoid (np .dot (w , a )+ b )
127
127
return a
128
128
129
129
def SGD (self , training_data , epochs , mini_batch_size , eta ,
@@ -220,7 +220,7 @@ def backprop(self, x, y):
220
220
for b , w in zip (self .biases , self .weights ):
221
221
z = np .dot (w , activation )+ b
222
222
zs .append (z )
223
- activation = sigmoid_vec (z )
223
+ activation = sigmoid (z )
224
224
activations .append (activation )
225
225
# backward pass
226
226
delta = (self .cost ).delta (zs [- 1 ], activations [- 1 ], y )
@@ -234,7 +234,7 @@ def backprop(self, x, y):
234
234
# that Python can use negative indices in lists.
235
235
for l in xrange (2 , self .num_layers ):
236
236
z = zs [- l ]
237
- spv = sigmoid_prime_vec (z )
237
+ spv = sigmoid_prime (z )
238
238
delta = np .dot (self .weights [- l + 1 ].transpose (), delta ) * spv
239
239
nabla_b [- l ] = delta
240
240
nabla_w [- l ] = np .dot (delta , activations [- l - 1 ].transpose ())
@@ -327,10 +327,6 @@ def sigmoid(z):
327
327
"""The sigmoid function."""
328
328
return 1.0 / (1.0 + np .exp (- z ))
329
329
330
- sigmoid_vec = np .vectorize (sigmoid )
331
-
332
330
def sigmoid_prime (z ):
333
331
"""Derivative of the sigmoid function."""
334
332
return sigmoid (z )* (1 - sigmoid (z ))
335
-
336
- sigmoid_prime_vec = np .vectorize (sigmoid_prime )
0 commit comments