我在处理一个热编码数据的向量,我在编码一个随机游走,其中的一个步骤是随机改变一个编码的维度,随机选取。你知道吗
代码如下:
MASK = random.choice(MASKS) #picks one of the ohencoded features (its mask)
SUB = X[MASK]
np.random.shuffle(SUB) #changes the ohencoded dimension by shuffling the 0s and single 1
X[MASK] = SUB #propagates back the new permutation
其中MASKS
是所有掩码的列表,每个编码特征一个,X
是随机游走器位置。你知道吗
切入正题,我正在寻找一种更干净、更优化的方法,在不必复制、排列和向后复制的情况下进行洗牌。有没有一种方法可以将numpy阵列的子阵列洗牌?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐