Exemple #1
0
def perlin_experiment(numpy_rng, run_index):
    recon = []

    ims_train, ims_test, ims_valid = load_data(image_dataset_path)
    spec_train, spec_test, spec_valid = load_data(spect_dataset_path)

    print ""
    print "Experiment 9: layer-wise model on images, initialized with perlin noise"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3], perlin=True)
    model.train(ims_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir,
                             "perlin_layerwise_images_only_%i.sda" % run_index)
    print "Training complete, saving model at %s" % save_path
    pickle.dump(model, open(save_path, 'wb'))
    recon_error = model.test(ims_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 10: layer-wise model on audio, initialized with perlin noise"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3], perlin=True)
    model.train(spec_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir,
                             "perlin_layerwise_audio_only_%i.sda" % run_index)
    print "Training complete, saving model at %s" % save_path
    pickle.dump(model, open(save_path, 'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    return recon
Exemple #2
0
def perlin_experiment(numpy_rng,run_index):
    recon = []

    ims_train, ims_test, ims_valid = load_data(image_dataset_path)
    spec_train, spec_test, spec_valid = load_data(spect_dataset_path)

    print ""
    print "Experiment 9: layer-wise model on images, initialized with perlin noise"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3], perlin=True )
    model.train( ims_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "perlin_layerwise_images_only_%i.sda"%run_index)
    print "Training complete, saving model at %s" % save_path                                            
    pickle.dump(model,open(save_path,'wb'))                                                              
    recon_error = model.test( ims_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 10: layer-wise model on audio, initialized with perlin noise"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3], perlin=True )
    model.train( spec_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path =os.path.join(model_save_dir, "perlin_layerwise_audio_only_%i.sda"%run_index)
    print "Training complete, saving model at %s" % save_path
    pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    return recon
Exemple #3
0
def combined(numpy_rng):
    recon = []

    ims_train, ims_test, ims_valid = load_data(image_dataset_path)
    spec_train, spec_test, spec_valid = load_data(spect_dataset_path)

    print ""
    print "Experiment 1: run ordinary model on images"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(ims_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir, "interleaved_images_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(ims_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 2: run greedy layer-wise pre-training on images"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(ims_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_images_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(ims_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 3: run ordinary model on spectrograms"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(spec_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir, "interleaved_spect_only.sda")
    print "Training complete, saving model at %s" % save_path
    pickle.dump(model, open(save_path, 'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 4: run greedy layer-wise pre-training on spectrograms"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(spec_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_spect_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error: %0.9f\n" % recon_error
    print ""
    recon.append(recon_error)

    print ""
    print "Experiment 5: train interleaved model on images, then spectrograms"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(ims_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    model.train(spec_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir,
                             "interleaved_images_then_spec.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test(ims_test)
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 6: train interleaved model on spectrograms, then images"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(spec_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    model.train(ims_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir,
                             "interleaved_spec_then_images.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test(ims_test)
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 7: train layer-wise model on images, then spectrograms"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(ims_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    model.train(spec_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_images_then_spec.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test(ims_test)
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 8: train layer-wise model on spectrograms, then images"
    model = SdA(numpy_rng, 1024, [256, 64, 16], [0.3, 0.3, 0.3])
    model.train(spec_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    model.train(ims_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_spec_then_images.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test(spec_test)
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test(ims_test)
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    return recon
Exemple #4
0
def combined(numpy_rng):
    recon = []

    ims_train, ims_test, ims_valid = load_data(image_dataset_path)
    spec_train, spec_test, spec_valid = load_data(spect_dataset_path)

    print ""
    print "Experiment 1: run ordinary model on images"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( ims_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir, "interleaved_images_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( ims_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 2: run greedy layer-wise pre-training on images"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( ims_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path =os.path.join(model_save_dir, "layerwise_images_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( ims_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 3: run ordinary model on spectrograms"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( spec_train, max_epochs=200, max_runtime=7200, layer_wise=False)
    save_path =os.path.join(model_save_dir, "interleaved_spect_only.sda")
    print "Training complete, saving model at %s" % save_path
    pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 4: run greedy layer-wise pre-training on spectrograms"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( spec_train, max_epochs=200, max_runtime=7200, layer_wise=True)
    save_path =os.path.join(model_save_dir, "layerwise_spect_only.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error: %0.9f\n" % recon_error
    print ""
    recon.append(recon_error)

    print ""
    print "Experiment 5: train interleaved model on images, then spectrograms"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( ims_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    model.train( spec_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir, "interleaved_images_then_spec.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test( ims_test )
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 6: train interleaved model on spectrograms, then images"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( spec_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    model.train( ims_train, max_epochs=100, max_runtime=7200, layer_wise=False)
    save_path = os.path.join(model_save_dir, "interleaved_spec_then_images.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test( ims_test )
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 7: train layer-wise model on images, then spectrograms"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( ims_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    model.train( spec_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_images_then_spec.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test( ims_test )
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    print ""
    print "Experiment 8: train layer-wise model on spectrograms, then images"
    model = SdA( numpy_rng, 1024, [256,64,16], [0.3,0.3,0.3] )
    model.train( spec_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    model.train( ims_train, max_epochs=100, max_runtime=7200, layer_wise=True)
    save_path = os.path.join(model_save_dir, "layerwise_spec_then_images.sda")
    #print "Training complete, saving model at %s" % save_path
    #pickle.dump(model,open(save_path,'wb'))
    recon_error = model.test( spec_test )
    print "Average reconstruction error on spectrograms: %0.9f" % recon_error
    recon_error = model.test( ims_test )
    print "Average reconstruction error on images: %0.9f\n" % recon_error
    recon.append(recon_error)

    return recon