@@ -45,7 +45,6 @@ def __init__(self):
45
45
46
46
self ._whether_apply_bias = False
47
47
self ._current_dimension = 0
48
- self ._cost_layer = "Undefined"
49
48
50
49
self ._logs = {}
51
50
self ._timings = {}
@@ -92,7 +91,6 @@ def initialize(self):
92
91
93
92
self ._whether_apply_bias = False
94
93
self ._current_dimension = 0
95
- self ._cost_layer = "Undefined"
96
94
97
95
self ._logs = []
98
96
self ._timings = {}
@@ -245,19 +243,6 @@ def _add_layer(self, layer, *args, **kwargs):
245
243
self ._current_dimension = _next
246
244
self ._update_layer_information (layer )
247
245
248
- @NNTiming .timeit (level = 4 )
249
- def _add_cost_layer (self , output_dim ):
250
- last_layer = self ._layers [- 1 ]
251
- last_layer_root = last_layer .root
252
- if not isinstance (last_layer , CostLayer ):
253
- if last_layer_root .name == "Sigmoid" or last_layer_root .name == "Softmax" :
254
- self ._cost_layer = "CrossEntropy"
255
- else :
256
- self ._cost_layer = "MSE"
257
- self .add (self ._cost_layer , (output_dim ,))
258
- else :
259
- self ._cost_layer = last_layer .cost_function
260
-
261
246
@NNTiming .timeit (level = 4 )
262
247
def _update_layer_information (self , layer ):
263
248
self ._layer_params .append (layer .params )
@@ -278,7 +263,7 @@ def _get_prediction(self, x, name=None, batch_size=1e6, verbose=None):
278
263
if not len (x ) % single_batch :
279
264
epoch += 1
280
265
name = "Prediction" if name is None else "Prediction ({})" .format (name )
281
- sub_bar = ProgressBar (max_value = epoch , name = name )
266
+ sub_bar = ProgressBar (max_value = epoch , name = name , start = False )
282
267
if verbose >= NNVerbose .METRICS :
283
268
sub_bar .start ()
284
269
rs , count = [self ._get_activations (x [:single_batch ], predict = True ).pop ()], single_batch
@@ -413,7 +398,7 @@ def _draw_detailed_network(self, show, radius=6, width=1200, height=800, padding
413
398
graph_group .append (data )
414
399
graphs .append (graph_group )
415
400
416
- img = np .ones (( height , width , 3 ), np .uint8 ) * 255
401
+ img = np .full ([ height , width , 3 ], 255 , dtype = np .uint8 )
417
402
axis0_padding = int (height / (layers - 1 + 2 * padding )) * padding + plot_num
418
403
axis0_step = (height - 2 * axis0_padding ) / layers
419
404
sub_layer_decrease = int ((1 - sub_layer_height_scale ) * axis0_step )
@@ -676,7 +661,7 @@ def preview(self):
676
661
) if isinstance (_layer , ConvLayer ) else "Layer : {:<10s} - {}" .format (
677
662
_layer .name , _layer .shape [1 ]
678
663
) for _layer in self ._layers [:- 1 ]
679
- ]) + "\n Cost : {:<10s}" .format (self ._cost_layer )
664
+ ]) + "\n Cost : {:<10s}" .format (str ( self ._layers [ - 1 ]) )
680
665
)
681
666
print ("=" * 30 + "\n " + "Structure\n " + "-" * 30 + "\n " + rs + "\n " + "-" * 30 + "\n " )
682
667
@@ -786,13 +771,13 @@ def fit(self,
786
771
layer_width = len (self ._layers )
787
772
self ._whether_apply_bias = apply_bias
788
773
789
- bar = ProgressBar (max_value = max (1 , epoch // record_period ), name = "Epoch" )
774
+ bar = ProgressBar (max_value = max (1 , epoch // record_period ), name = "Epoch" , start = False )
790
775
if self .verbose >= NNVerbose .EPOCH :
791
776
bar .start ()
792
777
img , ims = None , []
793
778
794
779
weight_trace = [[[org ] for org in weight ] for weight in self ._weights ]
795
- sub_bar = ProgressBar (max_value = train_repeat * record_period - 1 , name = "Iteration" )
780
+ sub_bar = ProgressBar (max_value = train_repeat * record_period - 1 , name = "Iteration" , start = False )
796
781
for counter in range (epoch ):
797
782
self ._w_optimizer .update ()
798
783
self ._b_optimizer .update ()
@@ -875,7 +860,7 @@ def fit(self,
875
860
if self .verbose >= NNVerbose .EPOCH :
876
861
bar .update (counter // record_period + 1 )
877
862
if self .verbose >= NNVerbose .ITER :
878
- sub_bar = ProgressBar (max_value = train_repeat * record_period - 1 , name = "Iteration" )
863
+ sub_bar = ProgressBar (max_value = train_repeat * record_period - 1 , name = "Iteration" , start = False )
879
864
880
865
if do_log :
881
866
self ._append_log (x_test , y_test , "test" , get_loss = show_loss )
0 commit comments