From 8d611ac1408b4b13b5b62702caa7cd2873ae5886 Mon Sep 17 00:00:00 2001 From: CezaryPukownik Date: Tue, 16 Jun 2020 10:17:50 +0200 Subject: [PATCH] Add default folder and add history storing feature --- project/generated_music/readme.md | 1 + project/midi_packs/readme.md | 2 ++ project/models/readme.md | 1 + project/train.py | 7 +++++-- project/training_sets/readme.md | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 project/generated_music/readme.md create mode 100644 project/midi_packs/readme.md create mode 100644 project/models/readme.md create mode 100644 project/training_sets/readme.md diff --git a/project/generated_music/readme.md b/project/generated_music/readme.md new file mode 100644 index 0000000..e738105 --- /dev/null +++ b/project/generated_music/readme.md @@ -0,0 +1 @@ +In this folder generated music will be stored diff --git a/project/midi_packs/readme.md b/project/midi_packs/readme.md new file mode 100644 index 0000000..07f3c7d --- /dev/null +++ b/project/midi_packs/readme.md @@ -0,0 +1,2 @@ +Place in this directory folders with midi. +Each folder represent a source for making trainig sets diff --git a/project/models/readme.md b/project/models/readme.md new file mode 100644 index 0000000..f7c9357 --- /dev/null +++ b/project/models/readme.md @@ -0,0 +1 @@ +In this directory trained models will be stored diff --git a/project/train.py b/project/train.py index 2f70fde..b2fc9e6 100644 --- a/project/train.py +++ b/project/train.py @@ -4,6 +4,7 @@ import pickle import keras import argparse import warnings +import pandas as pd from model import Seq2SeqModel from extract import make_folder_if_not_exist @@ -42,6 +43,7 @@ def train_models(model_workflow): if not INSTRUMENT or INSTRUMENT == instrument: data_path = os.path.join('training_sets', EXPERIMENT_NAME, instrument.lower() + '_data.pkl') model_path = os.path.join('models', EXPERIMENT_NAME, f'{instrument.lower()}_model.h5') + history_path = os.path.join('models', EXPERIMENT_NAME, f'{instrument.lower()}_history.csv') x_train, y_train, _, bars_in_seq = pickle.load(open(data_path,'rb')) @@ -52,8 +54,9 @@ def train_models(model_workflow): model = Seq2SeqModel(x_train, y_train, LATENT_DIM, ENCODER_DROPOUT, DECODER_DROPOUT, bars_in_seq) print(f'Training: {instrument}') - model.fit(BATCH_SIZE, EPOCHS, callbacks=[]) + history = model.fit(BATCH_SIZE, EPOCHS, callbacks=[]) make_folder_if_not_exist(os.path.join('models', EXPERIMENT_NAME)) + pd.DataFrame(history.history).to_csv(history_path, mode='a', header=False) model.save(model_path) found = True @@ -88,4 +91,4 @@ if __name__ == '__main__': if not DECODER_DROPOUT: DECODER_DROPOUT = 0.0 - train_models(load_workflow()) \ No newline at end of file + train_models(load_workflow()) diff --git a/project/training_sets/readme.md b/project/training_sets/readme.md new file mode 100644 index 0000000..321fe89 --- /dev/null +++ b/project/training_sets/readme.md @@ -0,0 +1 @@ +In this directory generated training sets will be stored