コード例 #1
0
def plot_glove_upto():
    for i in [500]:
        glove_data = utils.load_glove_data('train')
        glove_q = utils.load_glove_data('query')[:300]
        utils.plot_dist_hist_upto(glove_data, glove_q, i, 'glove')

    for i in [500]:
        glove_c_data = utils.load_glove_c_data('train')
        glove_c_q = utils.load_glove_c_data('query')[:300]
        utils.plot_dist_hist_upto(glove_c_data, glove_c_q, i, 'glove_c')
コード例 #2
0
def plot_glove():
    #glove_data = utils.load_sift_data('query')
    #pdb.set_trace()

    for i in [1, 100]:
        glove_data = utils.load_glove_data('train')
        glove_q = utils.load_glove_data('query')[:600]
        _, plt = utils.plot_dist_hist(glove_data, glove_q, i, 'glove')
    plt.clf()

    for i in [1, 100]:
        glove_c_data = utils.load_glove_c_data('train')
        glove_c_q = utils.load_glove_c_data('query')[:600]
        utils.plot_dist_hist(glove_c_data, glove_c_q, i, 'glove_c2')
コード例 #3
0
Demo for running training or linear models.
'''

import utils
from kahip.kmkahip import run_kmkahip

if __name__ == '__main__':
    opt = utils.parse_args()

    #adjust the number of parts and the height of the hierarchy
    n_cluster_l = [2]
    height_l = [1]

    # load dataset
    if opt.glove:
        dataset = utils.load_glove_data('train').to(utils.device)
        queryset = utils.load_glove_data('query').to(utils.device)
        neighbors = utils.load_glove_data('answers').to(utils.device)
    elif opt.sift:
        dataset = utils.load_sift_data('train').to(utils.device)
        queryset = utils.load_sift_data('query').to(utils.device)
        neighbors = utils.load_sift_data('answers').to(utils.device)
    else:
        dataset = utils.load_data('train').to(utils.device)
        queryset = utils.load_data('query').to(utils.device)
        neighbors = utils.load_data('answers').to(utils.device)

    #specify which action to take at each level, actions can be km, kahip, train, or svm. Lower keys indicate closer to leaf.
    #Note that if 'kahip' is included, evaluation must be on training rather than test set, since partitioning was performed on training, but not test, set.
    #e.g.: opt.level2action = {0:'km', 1:'train', 3:'train'}
    opt.level2action = {0: 'train'}
コード例 #4
0
def compute_alpha_beta():
    #dataset = utils.load_sift_data('train').to(utils.device)
    dataset = utils.load_glove_data('train').to(utils.device)
    alpha, beta = utils.compute_alpha_beta(dataset, 10)
    print(alpha, beta)
    pdb.set_trace()