Beispiel #1
0
                          main_dir='hidden_layers/',
                          enc_act_func='sigmoid',
                          dec_act_func='sigmoid',
                          loss_func='mean_squared',
                          num_epochs=31,
                          batch_size=12,
                          dataset='cifar10',
                          xavier_init=1,
                          opt='adam',
                          learning_rate=0.001,
                          momentum=0.5,
                          corr_type='gaussian',
                          corr_frac=0.6,
                          verbose=1,
                          seed=-1)
                dae.fit(trX, val_dict, teX, restore_previous_model=False)
                dae.reset()

        # =============================================================================
        #         Testing learning rates
        # =============================================================================
        elif arg == 'lrs':
            feed_list = [0.00001, 0.0001, 0.001, 0.01, 0.1, 0.5, 1.0]
            for i in feed_list:
                print "\n Evaluating for lr=" + str(i)
                t = arg + '=' + str(i)
                dae = DAE(model_name=arg + '_model',
                          pickle_name=arg,
                          test_name=t,
                          n_components=256,
                          main_dir='hidden_layers/',
Beispiel #2
0
from LeNet5 import LeNet

from autoencoder import DenoisingAutoencoder as DAE

if sys.argv[1] =='dae':
    dae = DAE(model_name='dae_svm', pickle_name='svm', test_name='svm',
                 n_components=256, main_dir='dae/', 
                 enc_act_func='sigmoid', dec_act_func='none', 
                 loss_func='mean_squared', num_epochs=50, batch_size=20, 
                 dataset='cifar10', xavier_init=1, opt='adam', 
                 learning_rate=0.0001, momentum=0.5, corr_type='gaussian',
                 corr_frac=0.5, verbose=1, seed=1)    
    
    trX, trY, teX, teY = getdata.load_cifar10_dataset('../cifar-10-batches-py/', mode='supervised')
    val_dict = {}
    dae.fit(trX, val_dict, teX, restore_previous_model=True) 
    
    #dae.load_model(256, 'models/dae/dae_svm')
    dae_svm_train = dae.transform(trX, name='dae_svm_train_na', save=True)
    dae_svm_test = dae.transform(teX, name='dae_svm_test_na', save=True)

    
elif sys.argv[1]=='cnn':
    cifar_train = getdata.get_train()
    cifar_test = getdata.get_test()
    acc_list = []
    cnn = LeNet(lr=0.001, epochs=101, batch_size=256, train_data=cifar_train,
                         test_data=cifar_test, wd=0.004, decay_lr=False,
                         decay_w=False, optimizer='rmsprop', seed=124, 
                         model_name='lenet/rmsprop', init_dev=0.01, drop=0.2)
    cnn.restore('models/lenet/rmsprop')