Skip to content

Commit d0e884d

Browse files
committed
indent custom_callback.py code
1 parent f9c55cf commit d0e884d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

custom_callbacks.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from keras.callbacks import Callback
22
from sklearn.metrics import precision_recall_fscore_support
33

4+
45
class Metrics(Callback):
56
def on_train_begin(self, logs={}):
67
self.valFMeasureHistory = []
@@ -23,19 +24,23 @@ def on_epoch_end(self, epoch, logs={}):
2324
if valFMeasure is None:
2425
valFMeasure = 0.0
2526

26-
2727
if valFMeasure > self.bestFMeasure:
28-
print('Updating best model')
29-
print('Current best model comes from epoch {}'.format(str(epoch)))
28+
print('Updating best model')
29+
print('Current best model comes from epoch {}'.format(str(epoch)))
3030
self.bestFMeasure = valFMeasure
3131
self.model.save('best-model.h5')
32-
32+
3333
self.valFMeasureHistory.append(valFMeasure)
3434
self.valRecallHistory.append(valRecall)
3535
self.valPrecisionHistory.append(valPrecision)
3636

3737
valMessageFmt = "val_f1:{}\tval_precision: {}\tval_recall: {}"
38-
print(valMessageFmt.format(round(valFMeasure,2), round(valPrecision,2), round(valRecall, 2)))
38+
print(
39+
valMessageFmt.format(
40+
round(
41+
valFMeasure, 2), round(
42+
valPrecision, 2), round(
43+
valRecall, 2)))
3944
print()
4045

4146
return

0 commit comments

Comments
 (0)