Closed zhshining closed 7 months ago
I just use 9 classes in Indian Pines dataset due to the sample unbalance,if you want to use all categories, just ignore the code
# comment these code
if self.data_name == 'Indian_pines':
imGIS = data_gt
origin_num = np.zeros(shape=[17], dtype=int)
for i in range(imGIS.shape[0]):
for j in range(imGIS.shape[1]):
for k in range(1, 17):
if imGIS[i][j] == k:
origin_num[k] += 1
index = 0
data_num = np.zeros(shape=[9], dtype=int) # per calsses's num
data_label = np.zeros(shape=[9], dtype=int) # original labels
for i in range(len(origin_num)):
if origin_num[i] > 400:
data_num[index] = origin_num[i]
data_label[index] = i
index += 1
iG = np.zeros([imGIS.shape[0], imGIS.shape[1]], dtype=imGIS.dtype)
for i in range(imGIS.shape[0]):
for j in range(imGIS.shape[1]):
if imGIS[i, j] in data_label:
for k in range(len(data_label)):
if imGIS[i][j] == data_label[k]:
iG[i, j] = k + 1
continue
imGIS = iG
data_gt = imGIS
self.data_gt = data_gt
in data_loader.py, and set your own train number for peer class in
for k, v in data_pos.items():
if self.train_num > 0 and self.train_num < 1:
train_num = self.train_num * len(v)# set your percentage
else:
train_num = self.train_num# set your own train per class, notice some class may don't have sampel more than 400 in IndianPines
train_pos[k] = random.sample(v, int(train_num))
test_pos[k] = [i for i in v if i not in train_pos[k]]
hi, i was trying to use 1D_CNN to classcify all 16 classes, but when I rectified the 'data_loader' and 'get_result', the program reported wrong:'ValueError: Sample larger than population or is negative'. My revisions were as follow: How can I do? please kindly tell me.