Now I need to randomize an existing tensor of m*m and make sure all rows or columns will not stay in the original position, the shuffle() function provided by python can only achieve the randomization function, but can not guarantee that all elements are moved. Alternatively, a diagonal matrix can be randomly disordered to ensure that there are no zeros on the diagonal and that element 1 appears only once in each row and column, and multiplying this matrix with the original matrix will also achieve the above function, but how to generate such a matrix is also a problem. If anyone knows how to solve this problem, please reply to me, I would be very grateful!
Asked
Active
Viewed 27 times
1 Answers
0
Representing a shuffling via indices or via a binary matrix are equivalent. In both cases you may have instances that are mapped back to themselves: either by having 1's on the diagonal of the binary matrix or by shuffled indices that equal their relative position.

Shai
- 111,146
- 38
- 238
- 371
-
Thank you for your reply, I know the above two situations will occur, that's why I ask whether there is any good way to solve the above problem – CaponeBoom Aug 08 '22 at 15:09
-
@CaponeBoom see the thread in the duplicate close vote. – Shai Aug 08 '22 at 15:16