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