Exemplo n.º 1
0
    # im_, gt_ = 'Pavia', 'Pavia_gt'
    # im_, gt_ = 'Botswana', 'Botswana_gt'
    # im_, gt_ = 'KSC', 'KSC_gt'

    img_path = root + im_ + '.mat'
    gt_path = root + gt_ + '.mat'
    print(img_path)

    p = Processor()
    img, gt = p.prepare_data(img_path, gt_path)
    # Img, Label = Img[:256, :, :], Label[:256, :]
    n_row, n_column, n_band = img.shape
    X_img = minmax_scale(img.reshape(n_row * n_column, n_band)).reshape(
        (n_row, n_column, n_band))
    img_correct, gt_correct = p.get_correct(X_img, gt)
    gt_correct = p.standardize_label(gt_correct)
    X_img_2D = X_img.reshape(n_row * n_column, n_band)
    train_inx, test_idx = p.get_tr_tx_index(gt_correct, test_size=0.4)

    n_input = [n_row, n_column]
    kernel_size = [11]
    n_hidden = [32]
    batch_size = n_band
    model_path = './pretrain-model-COIL20/model.ckpt'
    ft_path = './pretrain-model-COIL20/model.ckpt'
    logs_path = './pretrain-model-COIL20/logs'

    batch_size_test = n_band

    iter_ft = 0
    display_step = 1
Exemplo n.º 2
0
'''
# keys = ['Iris', 'Wine', 'wdbc', 'cotton', 'vowel', 'yeast', 'soybean']
keys = ['yeast', 'satellite', 'shuttle']
if __name__ == '__main__':
    acc_final = {}
    for key in keys:
        print('processing ', key)
        data = mat[key]
        X, y = data[:, 1:].astype('float32'), data[:, 0].astype('int8')
        classes = np.unique(y)
        for c in classes:
            if np.nonzero(y == c)[0].shape[0] < 10:
                X = np.delete(X, np.nonzero(y == c), axis=0)
                y = np.delete(y, np.nonzero(y == c))
        p = Processor()
        y = p.standardize_label(y)
        X = minmax_scale(X)
        print('num classes:', np.unique(y).__len__(), X.shape)

        # # execute classification
        # X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.6, stratify=y)
        # he_elm = HE_ELM([[BaseELM(10, dropout_prob=0.9)]*5, ]*1, KELM(C=1e-5, kernel='rbf'), is_nonmlize=True)
        accs_outer = []
        n_learner = 30
        n_hidden = 20
        # range_ = range(10) if X.shape[0] >= 1000 else range(20)
        for j in range(10) if X.shape[0] >= 2000 else range(20):
            X_train, X_test, y_train, y_test = train_test_split(X,
                                                                y,
                                                                train_size=0.6,
                                                                stratify=y)
Exemplo n.º 3
0
import numpy as np

if __name__ == '__main__':
    # root = '/Users/cengmeng/PycharmProjects/python/Deep-subspace-clustering-networks/Data/'
    root = '/content/'
    # im_, gt_ = 'SalinasA_corrected', 'SalinasA_gt'
    im_, gt_ = 'Indian_pines_corrected', 'Indian_pines_gt'
    # im_, gt_ = 'Pavia', 'Pavia_gt'
    # im_, gt_ = 'KSC', 'KSC_gt'

    img_path = root + im_ + '.mat'
    gt_path = root + gt_ + '.mat'

    p = Processor()
    img, gt = p.prepare_data(img_path, gt_path)
    n_row, n_column, n_band = img.shape
    train_inx, test_idx = p.get_tr_tx_index(p.get_correct(img, gt)[1],
                                            test_size=0.9)

    img = minmax_scale(img.reshape(n_row * n_column, n_band)).reshape(
        (n_row, n_column, n_band))

    x_input = img.reshape(n_row * n_column, n_band)

    num_class = 15
    snmf = BandSelection_SNMF(num_class)
    X_new = snmf.predict(x_input).reshape(n_row, n_column, num_class)
    a, b = p.get_correct(X_new, gt)
    b = p.standardize_label(b)
    print(eval_band_cv(a, b, times=5))