def kmeans_anneal(X,Y,idx_condensor,name):
    import time
    import pickle
    import numpy as np
    from subset_selection.rec_annealing import anneal_optimize


    cond_anneal = []

    for index in idx_condensor:
        cond_anneal.append(anneal_optimize(index, X, Y))
        pickle.dump(cond_anneal, open('data_sub/'+name+'_kmeans_anneal.p', 'wb'))
        print('saved_kmeans_anneal', len(index))
def random_anneal(X,Y,name,size=100,frac=1.1,tl=60,trial=1):
    import time
    import pickle
    import numpy as np
    from subset_selection.rec_annealing import anneal_optimize

    #X, Y = pickle.load(open('data_embed/mnist_dim32.p', 'rb'))


    cond_anneal = []

    while size < len(Y):

        for i in range(trial):
            index = np.random.choice(list(range(len(Y))), size, replace=False)
            cond_anneal.append(anneal_optimize(index, X, Y, tl))
        pickle.dump(cond_anneal, open('data_sub/'+name+'_random_anneal.p', 'wb'))
        size = int(size * frac)
        print('saved_random_anneal', size)
def flat_anneal(X_tr_emb,Y_tr,idx_condensor,name,size = 100):
    import pickle
    from subset_selection.rec_annealing import anneal_optimize
    #data_path = 'data_sub/mnist_tiers.p'
    #idx_condensor = index
    #print(idx_condensor.shape)
    X, Y = X_tr_emb, Y_tr

    #size = 100
    frac = 1.1
    cond_anneal = []

    while size < idx_condensor.shape[0]:
        index = idx_condensor[:size]
        tl = 60
        #if size == 100:
        #    tl = 300
        cond_anneal.append(anneal_optimize(index, X, Y, tl))
        pickle.dump(cond_anneal, open('data_sub/'+name+'_tiers_anneal.p', 'wb'))
        size = int(size * frac)
        print('saved_anneal', size)
Exemplo n.º 4
0
import time
import pickle
import numpy as np
from subset_selection.rec_annealing import anneal_optimize

data_path = 'data_sub/mnist_tiers.p'
idx_condensor = pickle.load(open(data_path, "rb"))
print(idx_condensor.shape)
X, Y = pickle.load(open('data_embed/mnist_dim32.p', 'rb'))

size = 100
frac = 1.1
cond_anneal = []

while size < idx_condensor.shape[0]:
    index = idx_condensor[:size]
    tl = 60
    if size == 100:
        tl = 300
    cond_anneal.append(anneal_optimize(index, X, Y, tl))
    pickle.dump(cond_anneal, open('data_sub/condensor_anneal.p', 'wb'))
    size = int(size * frac)
    print('saved', size)