# nb_iterations = 500 mixed_data.adjust_split_size_to_batchsize(batch_size) nb_batches = mixed_data.nb_batches(batch_size) nb_epochs = 1 time_spent = [0 for _ in range(5)] for epoch in range(nb_epochs): for b in range(nb_batches): step = nb_batches * epoch + b X_non_mix, X_mix, Ind = mixed_data.get_batch(batch_size) t = time.time() c = model.train_no_sum(X_mix, X_non_mix, learning_rate, step, ind_train=Ind) t_f = time.time() time_spent = time_spent[1:] + [t_f - t] print 'Step #', step, ' loss=', c, ' ETA = ', getETA( sum(time_spent) / float(np.count_nonzero(time_spent)), nb_batches, b, nb_epochs, epoch) # print 'length of data =', X_non_mix.shape ,'step ', b+1, mixed_data.datasets[0].index_item_split, mixed_data.selected_split_size(),getETA(sum(time_spent)/float(np.count_nonzero(time_spent)), nb_batches, b, nb_epochs, epoch) if b % 20 == 0: #cost_valid < cost_valid_min: print 'DAS model saved at iteration number ', step, ' with cost = ', c model.save(b) model.savedModel()
males = H5PY_RW() males.open_h5_dataset('test_raw.h5py', subset=males_keys(H5_dico)) males.set_chunk(5 * 4 * 512) males.shuffle() print 'Male voices loaded: ', males.length(), ' items' fem = H5PY_RW() fem.open_h5_dataset('test_raw.h5py', subset=females_keys(H5_dico)) fem.set_chunk(5 * 4 * 512) fem.shuffle() print 'Female voices loaded: ', fem.length(), ' items' Mixer = Mixer([males, fem], with_mask=False, with_inputs=True) adapt_model = Adapt() print 'Model DAS created' adapt_model.init() cost_valid_min = 1e10 Mixer.select_split(0) learning_rate = 0.005 for i in range(config.max_iterations): X_in, X_mix, Ind = Mixer.get_batch(1) c = adapt_model.train(X_mix, X_in, learning_rate, i) print 'Step #', i, ' ', c if i % 20 == 0: #cost_valid < cost_valid_min: print 'DAS model saved at iteration number ', i, ' with cost = ', c adapt_model.save(i)