-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
7,536 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+107 KB
...er_execute/00b86cf553e61db9b1d9039084ecb3de176c5128f74e1d9cbf226df4fd4b098c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.9 KB
...er_execute/05bb23a35be292dacca29115895aa30b477b3702733812dc88eedec9108561fd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.5 KB
...er_execute/0f4e455010d95626191b2c7cf3b5bb49f9aeaa9a4b91c3d3a77728209e542b28.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+80.2 KB
...er_execute/0f87b4789d1dea68deb5dbd5c8169c3307774631e0c4720e8230b5bf13ceb4ab.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+88.3 KB
...er_execute/1003c63cf4d33f7a19fa2966dbb8efaebbb8cded2d1f307be357976833342305.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.1 KB
...er_execute/15961ee4ef682feb0773b21475bcaf9571ce3cbffdcdb03e80c24b12e8c1433d.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.4 KB
...er_execute/18f69ae6eccfcaef9677e0db0e0223dcf2011fdc33c3c65f17dcf5b56f154725.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.8 KB
...er_execute/1f70d964adae8f5937528754bfbf018926b44f563247167c283ba3d6ec6912af.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+92.4 KB
...er_execute/2d19a4031347cfcde5655f0dcfceefec27aaf73fcc741ab1ab0195ccd943b251.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.1 KB
...er_execute/30eacca7324ff8d5eb2b8a221da4d1e31e83a9da73b5f02656c038110f164fc5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.8 KB
...er_execute/31f31c028cd32511865d9b4377790afc32485c5d30387adc29f6007cdf70df7f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+63.4 KB
...er_execute/3594e0999cf561fa210f5aa128dc8c1bdf1cd54cfc522303870b7ac0996d6d81.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+68.3 KB
...er_execute/36e975676dc3c37f488f6a644a09d8b0f059858482001b8b13a7a2a830677a7a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.3 KB
...er_execute/411ad01b915cabb08f441d57ed6c1395642c93fdba43c5ab6a3664995bb157ab.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+131 KB
...er_execute/42e6d26af2159c983a442fa87ce71bc8d4af03073a37f56384a0f6aa07bccd4b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+72.6 KB
...er_execute/51ad2dee4a168546bfaf845facb661b5f4436899bd96e179ff9ea85aca33ae9c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.3 KB
...er_execute/5334ee66c97affed7823118c36b355c37407fbaaa038895e0872fe8090ce816a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+85.8 KB
...er_execute/59e6ffa2a5eeba3ca1f8907236c54231658e8f1b0a9a792d95781be7d5b8c1fd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.4 KB
...er_execute/6f8b4b2ebfcd0679a3727b0192658ca56d59490c9c0362db4d3cea0224fd2429.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.1 KB
...er_execute/7270f0505dfe5c4c4083e0aa090c5ddf270ca488482cda44c8b6c315075f226f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+129 KB
...er_execute/72cd6540b8d8c6b5fd1039cfe919928abc36b30a1f5e220e687cd807fe104fcc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+102 KB
...er_execute/7876649fe14736f36ea3121f36405b25aa875478aa7bfdd42fa94e78abe45ceb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.7 KB
...er_execute/7962da1c27c61360e1c35f7f230b67c31fe8dfe3fefeb90e1e63d25c2865a2ce.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...er_execute/8866e0d0472b30efbee828d80f76edc46540e0bb8ac2fb22e0e38319c5287c3c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.7 KB
...er_execute/8aa7e22a172f489f402d455824660ee508d1837b7b4e209d2e2374fd0443f39a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.2 KB
...er_execute/9a879c388a68d6b65ccfd5b822a225ff9453cf3c1647ae1c3e5e6813ef9b5a83.jpg
Oops, something went wrong.
Binary file added
BIN
+143 KB
...er_execute/a0597b24513779a6876e1003b3c0aee8bb6693276d5901190b86a2efa59e42de.jpg
Oops, something went wrong.
Binary file added
BIN
+11.9 KB
...er_execute/a6f5b756241918250a1f5e8a45f2cc509c003233ff7eaaf5870f0c5ca62b7473.jpg
Oops, something went wrong.
Binary file added
BIN
+186 KB
...er_execute/b5b6635b8c13e3b79594f06a6bd2c4fca4781f6810494c4286fc7b2aca32f2d1.jpg
Oops, something went wrong.
Binary file added
BIN
+14.3 KB
...er_execute/b919c302a83f2ef38e79ccbb5c939bb0f5336a657168bc9b2e010da4cd1d56cd.jpg
Oops, something went wrong.
Binary file added
BIN
+24.7 KB
...er_execute/bd4feef74fd6786267ce2fc20695be861a5c06f7e4b973ee72c6ba79292d6f5d.jpg
Oops, something went wrong.
Binary file added
BIN
+32.8 KB
...er_execute/c3b46f8cc6ce88b46b7b54dec7c7182ca88ccb66249098a0101904dab6e2ee05.png
Oops, something went wrong.
Binary file added
BIN
+68.1 KB
...er_execute/d9ecc34617ef75d86ce90957aca0103c23f426fdcf89347c7780d7528c30a00a.png
Oops, something went wrong.
Binary file added
BIN
+84.7 KB
...er_execute/e3eb93d28f5c2028549805bd3181ff21fea996bb882fe6a99c80a2506f68339f.jpg
Oops, something went wrong.
Binary file added
BIN
+57.7 KB
...er_execute/eb4201de71c8575059afc78398a57c865d785ca997ac7f55fb269ab8d605e524.jpg
Oops, something went wrong.
Binary file added
BIN
+50.8 KB
...er_execute/fe1262a9629ae4f353920933ba7773c9101afee6ae8ab2c3e6f14199ca7be0b6.png
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import das.utils, das.data, das.train, das.io, das.evaluate, das.predict\n", | ||
"from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint\n", | ||
"import flammkuchen" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Load the model\n", | ||
"Change `model_savename` - if the model is saved at `res/20220601_103543_model.h5`, then `model_savename=\"res/20220601_103543\"`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model_savename = 'res/20220601_103543'\n", | ||
"model, params = das.utils.load_model_and_params(model_savename)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Load the data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = das.io.load(params['data_dir'], x_suffix=params['x_suffix'], y_suffix=params['y_suffix'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Prep the data for tensorflow" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data_gen = das.data.AudioSequence(data['train']['x'],\n", | ||
" data['train']['y'],\n", | ||
" shuffle=True,\n", | ||
" **params)\n", | ||
"val_gen = das.data.AudioSequence(data['val']['x'],\n", | ||
" data['val']['y'],\n", | ||
" shuffle=False,\n", | ||
" **params)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Prep callbacks\n", | ||
"The new model will be saved to `model_savename + \"_continued_model.h5\"`, in our example \"res/20220601_103543_continued_model.h5\"." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"das.utils.save_params(params, model_savename + \"_continued\")\n", | ||
"\n", | ||
"checkpoint_save_name = model_savename + \"_continued_model.h5\" # this will overwrite intermediates from previous epochs\n", | ||
"callbacks = [\n", | ||
" ModelCheckpoint(checkpoint_save_name, save_best_only=True, save_weights_only=False, monitor='val_loss', verbose=1),\n", | ||
" EarlyStopping(monitor='val_loss', patience=20, verbose=1),\n", | ||
"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Fit the model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fit_hist = model.fit(\n", | ||
" data_gen,\n", | ||
" epochs=params['nb_epoch'],\n", | ||
" steps_per_epoch=min(len(data_gen), 100),\n", | ||
" verbose=params['verbose'],\n", | ||
" validation_data=val_gen,\n", | ||
" callbacks=callbacks,\n", | ||
" class_weight=params['class_weights'],\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Test the model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(f' Re-loading last best model from {checkpoint_save_name}.')\n", | ||
"model.load_weights(checkpoint_save_name)\n", | ||
"\n", | ||
"print(' Predicting.')\n", | ||
"x_test, y_test, y_pred = das.evaluate.evaluate_probabilities(x=data['test']['x'], y=data['test']['y'], model=model, params=params)\n", | ||
"\n", | ||
"labels_test = das.predict.labels_from_probabilities(y_test)\n", | ||
"labels_pred = das.predict.labels_from_probabilities(y_pred)\n", | ||
"\n", | ||
"print(' Evaluating.')\n", | ||
"conf_mat, report = das.evaluate.evaluate_segments(labels_test, labels_pred, params['class_names'], report_as_dict=True)\n", | ||
"print(conf_mat)\n", | ||
"print(report)\n", | ||
"\n", | ||
"save_filename = \"{0}_results.h5\".format(model_savename + \"_continued\")\n", | ||
"print(f' Saving to {save_filename}.')\n", | ||
"ddd = {\n", | ||
" # 'fit_hist': fit_hist.history,\n", | ||
" 'confusion_matrix': conf_mat,\n", | ||
" 'classification_report': report,\n", | ||
" 'x_test': x_test,\n", | ||
" 'y_test': y_test,\n", | ||
" 'y_pred': y_pred,\n", | ||
" 'labels_test': labels_test,\n", | ||
" 'labels_pred': labels_pred,\n", | ||
" 'params': params,\n", | ||
"}\n", | ||
"flammkuchen.save(save_filename, ddd)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"interpreter": { | ||
"hash": "7ea0ec616133ead53c1908c8f6539f5c0cb9b2f78368e2bb6ab3f847e89ca400" | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3.9.9 ('base')", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.