【code】

import numpy as np

# 创建随机交换的索引
permutation = list(np.random.permutation(3))

# 创建矩阵X,Y
X = np.array([[0, 1, 2], [0, 1, 2], [0, 1, 2]])
Y = np.array([[0, 1, 2]])

# 交换顺序
shuffled_X = X[:, permutation]
shuffled_Y = Y[:, permutation]

# 输出
print("permutation:")
print(permutation)

print("X:")
print(X)
print("Y:")
print(Y)

print("shuffled_X:")
print(shuffled_X)
print("shuffled_Y:")
print(shuffled_Y)

【result】

permutation:
[1, 2, 0]
X: [[0
1 2] [0 1 2] [0 1 2]]
Y: [[0
1 2]]
shuffled_X: [[
1 2 0] [1 2 0] [1 2 0]]
shuffled_Y: [[
1 2 0]]

 

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2022-02-01
  • 2021-12-07
  • 2022-12-23
  • 2021-04-25
  • 2021-12-12
  • 2021-12-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-08-01
  • 2021-07-31
  • 2021-07-26
相关资源
相似解决方案