zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    P1371 NOI元丹
    最小费用最大流
    City Game UVALive
    P2389 电脑班的裁员
    P1959 遗址_NOI导刊2009普及(6)
    P2700 逐个击破
    P1630 求和
    P4310 绝世好题
    java常用类:1。包装类(以Integer类为例)2.String类 3.StringBuffer
    java异常,异常处理,异常类 关键字:throws 和 throw 自定义的异常类
  • 原文地址:https://www.cnblogs.com/gaona666/p/12294659.html
Copyright © 2011-2022 走看看