• plt画log图


    import matplotlib.pyplot as plt
    import math
    import numpy as np
    x = np.arange(-0.85,0.95,0.05)
        #获得函数结果
    y1 = [math.log(1-a) for a in x]
        #画图
    plt.plot(x, y1, linewidth=2, color='#007500', label='log1.5(x)')
    plt.legend(loc='lower right')#在右下角显示计算用的函数
    plt.grid(True)#在坐标系上画格子
        #打印图片
    plt.show()

     y = log(1-a)

     y = log(a)

    import matplotlib.pyplot as plt
    import math
    import numpy as np
    x = np.arange(-10,10,0.005)
        #获得函数结果
    max = 10
    min = -10
    
    
    y1 = [math.log(1-(a-min)/(max-min)) for a in x]
        #画图
    plt.plot(x, y1, linewidth=2, color='#007500', label='Minimax loss') 
           
    y2 = [-math.log((b+0.001-min)/(max-min)) for b in x]
        #画图
    plt.plot(x, y2, linewidth=2, color='red', label='Non-saturating loss')
    
    plt.xlabel("X",fontsize=14)
    plt.ylabel("Loss",fontsize=14) 
    plt.legend(loc='top right')#在右下角显示计算用的函数
    plt.grid(True)#在坐标系上画格子
        #打印图片
    plt.show() 

    import matplotlib.pyplot as plt
    import math
    import numpy as np
    x = np.arange(-10,10,0.005)
        #获得函数结果
    max = 10
    min = -10
    x3 = np.arange(0.005,100,0.0005)         
    y3 = [-(a-min)/(max-min) for a in x]
    plt.plot(x, y3, linewidth=2, color='blue', label='linear loss')        
    plt.xlabel("X",fontsize=14)
    plt.ylabel("Loss",fontsize=14) 
    plt.legend(loc='top right')#在右下角显示计算用的函数
    plt.grid(True)#在坐标系上画格子
        #打印图片
    plt.show()

  • 相关阅读:
    .NET Core 使用Dapper 操作MySQL
    .NET Core HtmlAgilityPack HTML解析利器
    ASP.NET Core 开发-缓存(Caching)
    .NET Core 调用WCF 服务
    ASP.NET Core 开发-Logging 使用NLog 写日志文件
    Qt动态生成界面并通过拉姆达获取其返回值
    Qt启动C++线程并在线程中修改界面
    Vector求最大值最小值
    C/C++取消结构体字节对齐
    Matlab定时器
  • 原文地址:https://www.cnblogs.com/gaona666/p/12294659.html
Copyright © 2020-2023  润新知