Skip to content

Commit

Permalink
move from .h5 model format to .keras format
Browse files Browse the repository at this point in the history
  • Loading branch information
haverland committed Dec 22, 2024
1 parent f1821b5 commit d2c44cb
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 608 deletions.
833 changes: 240 additions & 593 deletions dig-class100-s2.ipynb

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions dig-class100-s2_bw.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@
"\n",
"#annealer = LearningRateScheduler(lambda x: 1e-3 * 0.98 ** x, verbose=0)\n",
"earlystop = EarlyStopping(monitor='val_loss', mode='min' , patience=25, verbose=1, restore_best_weights=True)\n",
"mc = ModelCheckpoint(output_tmp_dir + model_filename + '_best.h5', monitor='val_loss', mode='min', verbose=1, save_best_only=True, initial_value_threshold=.9)\n",
"mc = ModelCheckpoint(output_tmp_dir + model_filename + '_best.keras', monitor='val_loss', mode='min', verbose=1, save_best_only=True, initial_value_threshold=.9)\n",
"reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.85, patience=3, min_lr=1e-5, verbose=1)\n",
"history = model.fit(train_iterator, \n",
" validation_data=validation_iterator, \n",
Expand All @@ -985,7 +985,7 @@
" verbose=1)\n",
"\n",
"\n",
"#model.save(model_filename + '.h5')\n",
"#model.save(model_filename + '.keras')\n",
"\n",
"plot_acc_loss(history, \"Trainingsresults\")"
]
Expand Down Expand Up @@ -1039,7 +1039,7 @@
}
],
"source": [
"model = keras.models.load_model(output_tmp_dir + model_filename + '_best.h5')\n",
"model = keras.models.load_model(output_tmp_dir + model_filename + '_best.keras')\n",
"false_predicted_files = predict_meter_digits(model, x_data=xz_data, y_data=yz_data, f_data=fz_data, \n",
" max_delta=0.11)\n",
"fpf = pd.DataFrame(false_predicted_files)\n",
Expand Down Expand Up @@ -1143,7 +1143,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.10 ('mlp')",
"display_name": "mlp",
"language": "python",
"name": "python3"
},
Expand All @@ -1170,11 +1170,6 @@
"parameters": {},
"start_time": "2022-05-05T11:23:55.373564",
"version": "2.3.4"
},
"vscode": {
"interpreter": {
"hash": "4976e0179d97dd6d59b1329a76e601e17b789c2571b41c8b57f5fd69821c0dd3"
}
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions dig-class100_s0.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
"\n",
"#annealer = LearningRateScheduler(lambda x: 1e-3 * 0.98 ** x, verbose=0)\n",
"earlystop = EarlyStopping(monitor='val_accuracy', mode='max' , patience=25, verbose=1, restore_best_weights=True)\n",
"mc = ModelCheckpoint(model_filename + '_best.h5', monitor='val_accuracy', mode='max', verbose=1, save_best_only=True)\n",
"mc = ModelCheckpoint(model_filename + '_best.keras', monitor='val_accuracy', mode='max', verbose=1, save_best_only=True)\n",
"reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.8, patience=5, min_lr=1e-5, verbose=1)\n",
"history = model.fit(train_iterator, \n",
" validation_data=validation_iterator, \n",
Expand All @@ -402,7 +402,7 @@
" verbose=1)\n",
"\n",
"\n",
"#model.save(model_filename + '.h5')\n",
"#model.save(model_filename + '.keras')\n",
"\n",
"plot_acc_loss(history, \"Trainingsresults\")"
]
Expand All @@ -424,7 +424,7 @@
"metadata": {},
"outputs": [],
"source": [
"model = keras.models.load_model(model_filename + '_best.h5')\n",
"model = keras.models.load_model(model_filename + '_best.keras')\n",
"xz_data, yz_data, fz_data = shuffle(xz_data, yz_data, fz_data)\n",
"false_predicted_files = predict_meter_digits(model, x_data=xz_data, y_data=yz_data, f_data=fz_data, \n",
" max_delta=0.)\n",
Expand Down
6 changes: 3 additions & 3 deletions dig_class100-s1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@
"\n",
"#annealer = LearningRateScheduler(lambda x: 1e-3 * 0.98 ** x, verbose=0)\n",
"earlystop = EarlyStopping(monitor='val_loss', mode='min' , patience=25, verbose=1, restore_best_weights=True)\n",
"mc = ModelCheckpoint(output_tmp_dir + model_filename + '_best.h5', monitor='val_loss', mode='min', verbose=1, save_best_only=True, initial_value_threshold=.9)\n",
"mc = ModelCheckpoint(output_tmp_dir + model_filename + '_best.keras', monitor='val_loss', mode='min', verbose=1, save_best_only=True, initial_value_threshold=.9)\n",
"reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.85, patience=5, min_lr=1e-5, verbose=1)\n",
"history = model.fit(train_iterator, \n",
" validation_data=validation_iterator, \n",
Expand All @@ -1080,7 +1080,7 @@
" verbose=1)\n",
"\n",
"\n",
"#model.save(model_filename + '.h5')\n",
"#model.save(model_filename + '.keras')\n",
"\n",
"plot_acc_loss(history, \"Trainingsresults\")"
]
Expand Down Expand Up @@ -1146,7 +1146,7 @@
}
],
"source": [
"model = keras.models.load_model(output_tmp_dir + model_filename + '_best.h5')\n",
"model = keras.models.load_model(output_tmp_dir + model_filename + '_best.keras')\n",
"false_predicted_files = predict_meter_digits(model, x_data=xz_data, y_data=yz_data, f_data=fz_data, \n",
" max_delta=0.11)\n",
"fpf = pd.DataFrame(false_predicted_files)\n",
Expand Down

0 comments on commit d2c44cb

Please sign in to comment.