sess.run([loss], feed_dict={ train_flag: True, x: batch[1], y_true: batch[0] })) print("Iteration {}, Loss {}".format(i + 1, loss_val)) val_loss_file.close() train_loss_file.close() # Save the variables to disk. save_path = saver.save( sess, "aux/model_checkpoints/{}_final.ckpt".format(model_name)) print("Model checkpoints will be saved in file: {}".format(save_path)) truth, example = read_file_pair(val_truth_ds_pairs[1]) y_reco = model.eval(feed_dict={ train_flag: False, x: example.reshape(1, -1, 1) }, session=sess).flatten() print('difference between truth and example (first 20 elements)') print(truth.flatten()[:20] - example.flatten()[:20]) print('difference between truth and reconstruction (first 20 elements)') print(truth.flatten()[:20] - y_reco[:20]) print('writting output audio files') librosa.output.write_wav('full_train_validation_true.wav', y=truth.flatten(), sr=true_br)
print("Epoch {}, Loss {}".format((i + 1), loss_val)) train_loss_file.write('{}\n'.format(loss_val)) if write_tb: summary = sess.run([merged], feed_dict={ train_flag: True, x: batch[1], y_true: batch[0] }) train_writer.add_summary(summary, i) save_path = saver.save(sess, "aux/model_checkpoints/overtrain_final.ckpt") print("Model checkpoints will be saved in file: {}".format(save_path)) train_loss_file.close() truth, example = read_file_pair(train_truth_ds_pairs[example_number]) y_reco = model.eval(feed_dict={ train_flag: True, x: example.reshape(1, -1, 1) }, session=sess).flatten() print('difference between truth and example (first 20 elements)') print(truth.flatten()[:20] - example.flatten()[:20]) print('difference between truth and reconstruction (first 20 elements)') print(truth.flatten()[:20] - y_reco[:20]) print('writting output audio files') librosa.output.write_wav('overtrain_true.wav', y=truth.flatten(), sr=true_br) librosa.output.write_wav('overtrain_ds.wav', y=example.flatten(), sr=true_br)
test_loss_file = open('test_loss.txt', 'w') count = 0 for pair in next_batch(BATCH_SIZE, test_truth_ds_pairs): loss_test = sess.run([waveform_mse], feed_dict={train_flag: False, x: pair[1], y_true: pair[0]} ) test_loss_file.write('{}\n'.format(np.mean(loss_test))) print("Iteration {}, Test Loss {}".format((count + 1), loss_test)) count += 1 test_loss_file.close() truth, example = read_file_pair(test_truth_ds_pairs[0]) y_reco = model.eval(feed_dict={train_flag: False, x: example.reshape(1, -1, 1)}, session=sess).flatten() print('difference between truth and example (first 20 elements)') print(truth.flatten()[:20] - example.flatten()[:20]) print('difference between truth and reconstruction (first 20 elements)') print(truth.flatten()[:20] - y_reco[:20]) # if waveform_reduction_factor == 1: print('writting output audio files') librosa.output.write_wav('full_train_test_true.wav', y=truth.flatten(), sr=true_br) librosa.output.write_wav('full_train_test_ds.wav', y=example.flatten(), sr=true_br)