#生成一个[0,1)之间的随机浮点数或N维浮点数组。
#type(u)= <class 'numpy.ndarray'>
import numpy as np
n=6
k=2
np.random.seed(0)
u = np.random.rand(n, k)
np.random.seed(0)
v = np.random.rand(n, k)
np.random.seed(0)
w = np.random.rand(k, k)
print("type(u)=",type(u))
print("u=")
print(u)
print("v=")
print(v)
print("w=")
print(w)
D:\ProgramData\Anaconda3\python.exe D:/NetworkEfficiency/linkpred/nmfap/4-begin随机生成uvw.py
type(u)= <class ‘numpy.ndarray’>
u=
[[0.5488135 0.71518937]
[0.60276338 0.54488318]
[0.4236548 0.64589411]
[0.43758721 0.891773 ]
[0.96366276 0.38344152]
[0.79172504 0.52889492]]
v=
[[0.5488135 0.71518937]
[0.60276338 0.54488318]
[0.4236548 0.64589411]
[0.43758721 0.891773 ]
[0.96366276 0.38344152]
[0.79172504 0.52889492]]
w=
[[0.5488135 0.71518937]
[0.60276338 0.54488318]]
Process finished with exit code 0