예제 #1
0
init = model.non_initialized_variables()

model.sess.run(init)

print 'Total name :' 
print model.runID

# 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):
		X_non_mix, X_mix, _ = mixed_data.get_batch(batch_size)
		t = time.time()
		c = model.train(X_mix, X_non_mix, learning_rate, b)
		t_f = time.time()
		time_spent = time_spent[1:] +[t_f-t]

		print 'Step #'  ,b,' 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 ', nb_batches*epoch + b,' with cost = ', c 
		    model.save(b)

예제 #2
0
mixed_data.adjust_split_size_to_batchsize(batch_size)
nb_batches = mixed_data.nb_batches(batch_size)
nb_epochs = 40

time_spent = [0 for _ in range(5)]
print 'NB BATCHES =', nb_batches
print 'NB ITERATIONS =', nb_batches * nb_epochs
print 'NB SAVE = ', (nb_batches * nb_epochs) / 20

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(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 step % 20 == 0:  #cost_valid < cost_valid_min:
            print 'DAS model saved at iteration number ', step, ' with cost = ', c
            model.save(nb_batches * epoch + b)
            mixed_data.select_split(1)
            x_non_test, x_test, _ = mixed_data.get_only_first_items(8)
            model.test_prediction(x_test, x_non_test, step)
            mixed_data.select_split(0)
예제 #3
0
    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)
예제 #4
0
folder = 'DAS_train_front'
model = Adapt(config_model=config_model, pretraining=False)
model.create_saver()

path = os.path.join(config.workdir, 'floydhub_model', "pretraining")
# path = os.path.join(config.log_dir, "pretraining")
model.restore_model(path, full_id)

from models.das import DAS

model.connect_only_front_to_separator(DAS)

init = model.non_initialized_variables()

# Model creation

# Pretraining the model

nb_iterations = 1000

#initialize the model
model.sess.run(init)

for i in range(nb_iterations):
    X_in, X_mix, Ind = mixed_data.get_batch(batch_size)
    c = model.train(X_mix, X_in, learning_rate, i, ind_train=Ind)
    print 'Step #', i, ' loss=', c

    if i % 20 == 0:  #cost_valid < cost_valid_min:
        print 'DAS model saved at iteration number ', i, ' with cost = ', c
        model.save(i)
예제 #5
0
model.sess.run(init)

print 'Total name :'
print model.runID

# 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):
        X_non_mix, X_mix, _ = mixed_data.get_batch(batch_size)
        t = time.time()
        c = model.train(X_mix, X_non_mix, learning_rate,
                        nb_batches * epoch + b)
        t_f = time.time()
        time_spent = time_spent[1:] + [t_f - t]

        print 'Step #', b, ' 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 ', nb_batches * epoch + b, ' with cost = ', c
            model.save(b)