@@ -30,22 +30,21 @@ def add_classifier_layer(net, num_outputs):
30
30
return net_classifier
31
31
32
32
def SGD_final_layer (
33
- self , training_data , epochs , mini_batch_size , eta , lmbda ,
34
- test = False , test_inputs = None , actual_test_results = None ):
33
+ self , training_data , epochs , mini_batch_size , eta , lmbda ):
35
34
"""
36
35
Run SGD on the final layer of the Network ``self``. Note that
37
36
``training_data`` is the input to the whole Network, not the
38
37
encoded training data input to the final layer.
39
38
"""
40
39
encoded_training_data = [
41
- (self .feedforward (x , start = 0 , end = - 1 ), y ) for x , y in training_data ]
42
- net = Network ([ self . sizes [ - 2 ], self . sizes [ - 1 ]])
43
- net . biases [ - 1 ] = self .biases [ - 1 ]
44
- net .weights [ - 1 ] = self .weights [- 1 ]
45
- net .SGD ( encoded_training_data , epochs , mini_batch_size , eta ,
46
- lmbda , test , test_inputs , actual_test_results )
47
- self .biases [- 1 ] = net .biases [- 1 ]
48
- self .weights [- 1 ] = net .weights [- 1 ]
40
+ (self .feedforward (x , start = 0 , end = self . num_layers - 2 ), y )
41
+ for x , y in training_data ]
42
+ net = Network ( self .sizes [ - 2 :])
43
+ net .biases [ 0 ] = self .biases [- 1 ]
44
+ net .weights [ 0 ] = self . weights [ - 1 ]
45
+ net . SGD ( encoded_training_data , epochs , mini_batch_size , eta , lmbda )
46
+ self .biases [- 1 ] = net .biases [0 ]
47
+ self .weights [- 1 ] = net .weights [0 ]
49
48
50
49
51
50
# Add the SGD_final_layer method to the Network class
0 commit comments