当前位置:   article > 正文

python numpy学习3_python numpy归一化0到1

python numpy归一化0到1

  1. 归一化,将矩阵规格化到01,即最小的变成0,最大的变成1,最小与最大之间的等比缩放。Z = np.random.random((5,5))



    import numpy as np


    Z = np.random.random((5,5))


    print(Z)


    max=Z.max()


    min=Z.min()


    print(max,min)


    Z=(Z-min)/(max-min)


    print(Z)


    输出结果:


    [[0.25303525 0.99681094 0.36594609 0.04002044 0.54792824]


     [0.06921534 0.406925850.1957492  0.07253186 0.86404351]


     [0.40006867 0.15025097 0.443783820.03820552 0.80692884]


     [0.7702267  0.99836316 0.26948848 0.39156013 0.49678772]


     [0.73695705 0.25479203 0.954615450.03215094 0.1828546 ]]


    0.9983631554021115 0.03215093610347419


    [[0.22860849 0.99839351 0.34546774 0.00814469 0.53381368]


     [0.03836052 0.38788054 0.169319180.04179302 0.86098328]


     [0.38078357 0.12222992 0.426027410.0062663  0.80187136]


     [0.76388577 1.         0.24563707 0.37197748 0.48088482]


     [0.72945271 0.2304267  0.95472247 0.         0.15597367]]

    代码实现:




声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/174460
推荐阅读
相关标签
  

闽ICP备14008679号