import numpy as np
# setting up matrices
np.random.seed(1234) # make example repeatable
# the seeding is optional, only for the showing the
# same results as below!
face_train = np.random.rand(8,3)
train_lbls= np.random.rand(8)
print('face_train:\n', face_train)
print('labels:\n', train_lbls)
# Setting the random indexes
random_idxs= np.random.randint(face_train.shape[0], size=4)
print('random_idxs:\n', random_idxs)
# Using the indexes to slice the matrixes
reduced_train_face = face_train[random_idxs, :]
reduced_labels = train_lbls[random_idxs]
print('reduced_train_face:\n', reduced_train_face)
print('reduced_labels:\n', reduced_labels)
可以在应用提取之前修复种子:
同样的种子,也会以同样的方式减少。在
编辑:我建议您使用^{} ,以确保每个数据只选择一次而不是两次相同的数据
为什么不保留所选索引并使用它们从两个矩阵中选择数据?在
作为输出:
^{pr2}$相关问题 更多 >
编程相关推荐