예제 #1
0
 def __init__(self,args):
     self.data_path = args.data_path
     self.train_num = args.train_num
     self.seed = args.seed
     self.data_name = args.data_name
     self.result = args.result
     self.tfrecords = args.tfrecords
     self.args = args
     self.value = args.threshold
     self.cube_length = args.cube_size * 2 + 1
     self.n_components=args.n_components
     self.cube_size = args.cube_size
     self.padding = args.padding
     if self.data_name == 'PaviaU' or self.data_name == 'Indian_pines' or self.data_name == 'Houston':
         self.data_dict = sio.loadmat(str(pathlib.Path(self.data_path, self.data_name + '.mat')))
     elif self.data_name == 'Salinas':
         self.data_dict = sio.loadmat(str(pathlib.Path(self.data_path, self.data_name + '_corrected.mat')))
     self.data_gt_dict = sio.loadmat(str(pathlib.Path(self.data_path, self.data_name+'_gt.mat')))
     data_name = [t for t in list(self.data_dict.keys()) if not t.startswith('__')][0]
     data_gt_name = [t for t in list(self.data_gt_dict.keys()) if not t.startswith('__')][0]
     self.data = self.data_dict[data_name]
     self.data = unit.max_min(self.data).astype(np.float32)
     shape0 = self.data.shape[0]
     shape1 = self.data.shape[1]
     data = np.reshape(self.data, [shape0 * shape1, -1])
     n_components = self.n_components
     pca = PCA(n_components=n_components, svd_solver="full")#PCA algorithm
     data = pca.fit(data).transform(data)
     self.data = np.reshape(data, [shape0, shape1, -1])
     self.data = np.lib.pad(self.data, ((self.padding, self.padding), (self.padding, self.padding), (0, 0)), 'symmetric')
     #print(self.data.shape)
     self.data_gt = self.data_gt_dict[data_gt_name].astype(np.int64)
     #print(self.data_gt.shape)
     self.dim = self.data.shape[2]
    def __init__(self, args):
        self.args = args
        self.data_path = args.data_path
        self.train_num = args.train_num
        self.fix_seed = args.fix_seed
        self.seed = args.seed
        self.tfrecords = args.tfrecords
        self.cube_size = args.cube
        self.data_name = args.data_name
        self.numComponents = args.numComponents

        self.data_dict = sio.loadmat(
            str(pathlib.Path(self.data_path, self.data_name + '.mat')))
        self.data_gt_dict = sio.loadmat(
            str(pathlib.Path(self.data_path, self.data_name + '_gt.mat')))
        data_name = [
            t for t in list(self.data_dict.keys()) if not t.startswith('__')
        ][0]
        data_gt_name = [
            t for t in list(self.data_gt_dict.keys()) if not t.startswith('__')
        ][0]
        self.data = self.data_dict[data_name]
        self.data = unit.max_min(self.data).astype(np.float32)
        self.data_gt = self.data_gt_dict[data_gt_name].astype(np.int64)
        #self.dim = self.data.shape[2]
        self.dim = self.numComponents
예제 #3
0
    def __init__(self, args):
        self.data_path = args.data_path
        self.train_num = args.train_num
        self.seed = args.seed
        self.data_name = args.data_name
        self.result = args.result
        self.tfrecords = args.tfrecords
        self.args = args
        self.cube_size = args.cube_size

        self.data_dict = sio.loadmat(
            str(pathlib.Path(self.data_path, self.data_name + '.mat')))
        self.data_gt_dict = sio.loadmat(
            str(pathlib.Path(self.data_path, self.data_name + '_gt.mat')))
        data_name = [
            t for t in list(self.data_dict.keys()) if not t.startswith('__')
        ][0]
        data_gt_name = [
            t for t in list(self.data_gt_dict.keys()) if not t.startswith('__')
        ][0]
        self.data = self.data_dict[data_name]
        self.data = unit.max_min(self.data).astype(np.float32)
        self.data_gt = self.data_gt_dict[data_gt_name].astype(np.int64)
        self.dim = self.data.shape[2]
        print('DataSet %s shape is %s' % (self.data_name, self.data.shape))