随机生成 指定范围内 指定个数 的 整数/生成随机整数
关键:使用numpy
import numpy as np
np.random.randint(0, high=100, size=50)
#随机生成0到100之间的不重复的整数,个数为50个
对比:生成固定整数
l_1 = [1]*20 #[1, 1, 1, ..., 1]
l_2 = [2]*20
label = l_1 + l_2 #[1,1,1,...,2,2,2,...]
关键:使用numpy
import numpy as np
np.random.randint(0, high=100, size=50)
#随机生成0到100之间的不重复的整数,个数为50个
对比:生成固定整数
l_1 = [1]*20 #[1, 1, 1, ..., 1]
l_2 = [2]*20
label = l_1 + l_2 #[1,1,1,...,2,2,2,...]