16
두 개의 numpy 배열을 동시에 섞는 더 좋은 방법
모양이 다른 두 개의 numpy 배열이 있지만 길이는 동일합니다 (선행 치수). 해당 요소가 계속 일치하도록 각 요소를 섞고 싶습니다. 즉, 선행 지수와 관련하여 일치하게 섞습니다. 이 코드는 작동하며 내 목표를 보여줍니다. def shuffle_in_unison(a, b): assert len(a) == len(b) shuffled_a = numpy.empty(a.shape, dtype=a.dtype) shuffled_b = numpy.empty(b.shape, dtype=b.dtype) permutation = numpy.random.permutation(len(a)) for …