Ejemplo n.º 1
0
def load_dict_data(dataset_path, is_linear, shape):
    if is_linear:
        train, test = load_data_vec(dataset_path)
    else:
        train, test = load_data_img(dataset_path, shape)

    train['data'] = np.asarray(train['data'], dtype='float32')
    test['data']  = np.asarray(test['data'] , dtype='float32')
    train['data'] = train['data'] / 255
    test['data']  = test['data']  / 255
    return train, test
Ejemplo n.º 2
0
        sys.exit(1)

    dataset_path = sys.argv[1]
    measure_type = sys.argv[2]
    output_folder = sys.argv[3]
    if not output_folder.endswith('/'):
        output_folder += '/'
    if not os.path.exists(output_folder):
        os.mkdir(output_folder)


    if not measure_type in ['cos', 'euc']:
        sys.stderr.write('Error: measure_type must be in [cos, euc]\n')
        sys.exit(1)

    train, test = load_data_vec(dataset_path)
    assert train['data'].shape[1] == test['data'].shape[1]
    # train['data'] = normalize_data(train['data'])
    # test['data']  = normalize_data(test['data'])
    train['data'] = np.asarray(train['data'], dtype='float64')
    test['data'] = np.asarray(test['data'], dtype='float64')
    print train['data'].shape
    print test['data'].shape

    sample_num, dim = test['data'].shape
    batch_len = 500
    batch_num = sample_num / batch_len

    engine = Engine(train, test, measure_type)
    # engine = FileNameEngine(train, test, measure_type)