我想在每个位置创建具有固定随机值的新矩阵(V)(每次运行算法时,我希望显示相同的矩阵)。是否可以将np.random.seed()用于矩阵?像
这样的东西V = np.zeros([20,50])
V = np.random.seed(V)
答案 0 :(得分:3)
使用它来设置种子:
np.random.seed(0) # or whatever value you fancy
然后生成随机数据:
V = np.random.rand(your_shape) # or whatever randomness you fancy like randint, randn ...