python画激活函数图像
导入必要的库
import math
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.rcParams['axes.unicode_minus'] = False
绘制softmax函数图像
fig = plt.figure(figsize=(6,4))
ax = fig.add_subplot(111)
x = np.linspace(-10,10)
y = sigmoid(x) ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none') ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.set_xticks([-10,-5,0,5,10])
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
ax.set_yticks([-1,-0.5,0.5,1]) plt.plot(x,y,label = 'Softmax',linestyle='-',color='blue')
plt.legend(['Softmax'])
plt.savefig('softmax.png')

绘制Relu激活函数图像
fig = plt.figure(figsize=(6,4))
ax = fig.add_subplot(111)
x = np.arange(-10,10)
y = np.where(x<0,0,x) # 小于0输出0,大于0输出y
plt.xlim(-11,11)
plt.ylim(-11,11) ax = plt.gca() # 获得当前axis坐标轴对象
ax.spines['right'].set_color('none') # 去除右边界线
ax.spines['top'].set_color('none') # 去除上边界线 ax.xaxis.set_ticks_position('bottom') # 指定下边的边作为x轴
ax.yaxis.set_ticks_position('left') # 指定左边的边为y轴 ax.spines['bottom'].set_position(('data',0)) # 指定data 设置的bottom(也就是指定的x轴)绑定到y轴的0这个点上
ax.spines['left'].set_position(('data',0)) # 指定y轴绑定到x轴的0这个点上 plt.plot(x,y,label = 'ReLU',linestyle='-',color='darkviolet')
plt.legend(['ReLU'])
plt.savefig('relu.png')

绘制Tanh激活函数图像
x = np.arange(-10,10)
a = np.array(x)
y = (math.e**(x) - math.e**(-x)) / (math.e**(x) + math.e**(-x)) plt.xlim(-11,11)
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left') ax.spines['bottom'].set_position(('data',0))
ax.spines['left'].set_position(('data',0))
plt.plot(x,y,label='Tanh',linestyle='-',color='green')
plt.legend(['Tanh'])
plt.savefig('Tanh.png',dpi=500) # 指定分辨率

python画激活函数图像的更多相关文章
- Python 画3D图像
绘制一副3D图像 draw3D(X,Y,Z, angle) import numpy as np from matplotlib import pyplot as plt from mpl_toolk ...
- 用python画函数图像
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 1, 50) # 从0到1,等分50分 y = 210*(x ...
- 沉淀再出发:用python画各种图表
沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as ...
- 跟我学Python图像处理丨图像特效处理:毛玻璃、浮雕和油漆特效
摘要:本文讲解常见的图像特效处理,从而让读者实现各种各样的图像特殊效果,并通过Python和OpenCV实现. 本文分享自华为云社区<[Python图像处理] 二十四.图像特效处理之毛玻璃.浮雕 ...
- 【python图像处理】图像的缩放、旋转与翻转
[python图像处理]图像的缩放.旋转与翻转 图像的几何变换,如缩放.旋转和翻转等,在图像处理中扮演着重要的角色,python中的Image类分别提供了这些操作的接口函数,下面进行逐一介绍. 1.图 ...
- Catlike学习笔记(1.2)-使用Unity画函数图像
『Catlike系列教程』第二篇来了~今天周六,早上(上午11点)醒来去超市买了一周的零食回来以后就玩了一整天游戏非常有负罪感.现在晚上九点天还亮着感觉像下午7点左右的样子好像还不是很晚...所以就写 ...
- python画樱花
用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): ...
- python 画小猪佩奇
转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @auth ...
- 用python画 pareto front
用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt im ...
随机推荐
- RTC
RTC的英文全称是Real-Time Clock,翻译过来是实时时钟芯片. RTC是PC主板上的晶振及相关电路组成的时钟电路的生成脉冲主板上的晶振及相关电路组成的时钟电路的生成脉冲,,RTC经过825 ...
- MySQL Warning: Using a password on the command line interface can be insecure.解决办法
转自 http://www.cnblogs.com/sunss/p/6256706.html 被一个小朋友问到,直接公布答案: If your MySQL client/server version ...
- bootstrap table 双击可编辑,添加、删除行
html: <table class="table table-bordered" id="para_table"> <tr> < ...
- HDU 6194 string string string 2017沈阳网络赛 后缀数组
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6194 题意:告诉你一个字符串和k , 求这个字符串中有多少不同的子串恰好出现了k 次. 解法:后缀数组 ...
- Ubuntu每次开机后提示:检测到系统程序出现问题的解决方法
首先,错误报告存放位置: cd /var/crash/ ls //可以查看错误报告 1 2 sudo rm /var/crash/* //删除该目录下的所有文件 1 但是,这只是删除掉的是错误报告,如 ...
- 11.python3标准库--使用进程、线程和协程提供并发性
''' python提供了一些复杂的工具用于管理使用进程和线程的并发操作. 通过应用这些计数,使用这些模块并发地运行作业的各个部分,即便是一些相当简单的程序也可以更快的运行 subprocess提供了 ...
- Windows Phone 8/Windows 8 启动第三方应用程序并传递参数
需要被其他应用启动的第三方应用需要注册protocol association,当一个应用程序启动一个特殊的URI的时候,那么注册了这个protocol的程序会自动启动,并且可以通过这个特殊的URI将 ...
- Effective C++笔记(五):实现
参考:http://www.cnblogs.com/ronny/p/3754755.html 条款26:尽可能延后变量定义式的出现时间 有些对象,你可能过早的定义它,而在代码执行的过程中发生了导常,造 ...
- hexdump related.
hexdump format strings Tue 13 December 2005 In tips. Ian Wienand More from the "things you'd le ...
- MYSQL-----控制流程函数(case when...then..else..end)
MySQL有一些内置的控制流程函数,可以在SQL语句中使用这些函数来更加准确和直接的结果. 第一种语法: case when [value] then result ................. ...