美文网首页
numpy生成随机矩阵

numpy生成随机矩阵

作者: 一路向后 | 来源:发表于2021-05-24 21:53 被阅读0次

    1.源码实现

    import numpy as np;
    import random as rd;
    
    A = np.random.rand(3)
    B = np.random.rand(3, 3)
    C = np.random.rand(3, 3, 3)
    
    print("A =", A)
    print("B =", B)
    print("C =", C)
    

    2.运行及其结果

    $ python3 random_1.py 
    A = [ 0.31880091  0.24481087  0.09568605]
    B = [[ 0.21711139  0.70239533  0.71976923]
     [ 0.8139679   0.49379826  0.19379585]
     [ 0.4712822   0.22926796  0.60298726]]
    C = [[[ 0.65977639  0.88701896  0.19543756]
      [ 0.45021699  0.34486738  0.0119728 ]
      [ 0.63649554  0.15397883  0.50004449]]
    
     [[ 0.98309559  0.27648943  0.71336816]
      [ 0.04985408  0.4521457   0.36350213]
      [ 0.05329061  0.97884136  0.12995352]]
    
     [[ 0.9055198   0.00220075  0.50801991]
      [ 0.31568117  0.20633831  0.05842598]
      [ 0.55251133  0.48417473  0.57347605]]]
    

    相关文章

      网友评论

          本文标题:numpy生成随机矩阵

          本文链接:https://www.haomeiwen.com/subject/ieefsltx.html