赞
踩
仅作为记录,大佬请跳过。
用test_set = random.sample(source_lst, int(0.2*len(source_lst)))
参考
用train_set = [x for x in source_lst if x not in test_set]
'''source中所有图块'''
source_dir = '/data_sda/dataset/source'
source_lst = glob.glob(os.path.join(source_dir, '*.tif'))
'''随机取训练集80%,测试集20%'''
import random
random.seed(0)
test_set = random.sample(source_lst, int(0.2*len(source_lst)))
'''取list中不包含的元素'''
train_set = [x for x in source_lst if x not in test_set]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。