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()

  • 相关阅读:
    Bean管理学习笔记
    Spring核心概念学习笔记
    Spring主要用到两种设计模式
    C# 值类型和引用类型等值判断
    嵌入式Linux之gdb配置和使用
    嵌入式Linux之telnet
    构建嵌入式Linux交叉编译工具链
    Linux动态库和静态库
    VxWorks BSP开发入门
    buildroot
  • 原文地址:https://www.cnblogs.com/gaona666/p/12294659.html
Copyright © 2011-2022 走看看