资源简介
浅层神经网络工具函数.zip

代码片段和文件信息
import matplotlib.pyplot as plt
import numpy as np
import sklearn
import sklearn.datasets
import sklearn.linear_model
def plot_decision_boundary(model X y):
# Set min and max values and give it some padding
x_min x_max = X[0 :].min() - 1 X[0 :].max() + 1
y_min y_max = X[1 :].min() - 1 X[1 :].max() + 1
h = 0.01
# Generate a grid of points with distance h between them
xx yy = np.meshgrid(np.arange(x_min x_max h) np.arange(y_min y_max h))
# Predict the function value for the whole grid
Z = model(np.c_[xx.ravel() yy.ravel()])
Z = Z.reshape(xx.shape)
# Plot the contour and training examples
plt.contourf(xx yy Z cmap=plt.cm.Spectral)
plt.ylabel(‘x2‘)
plt.xlabel(‘x1‘)
plt.scatter(X[0 :] X[1 :] c=y cmap=plt.cm.Spectral)
def sigmoid(x):
“““
Compute the sigmoid of x
Arguments:
x -- A scalar or numpy array of any size.
Return:
s -- sigmoid(x)
“““
s = 1/(1+np.exp(-x))
return s
def load_planar_dataset():
np.random.seed(1)
m = 400 # number of examples
N = int(m/2) # number of points per class
D = 2 # dimensionality
X = np.zeros((mD)) # data matrix where each row is a single example
Y = np.zeros((m1) dtype=‘uint8‘) # labels vector (0 for red 1 for blue)
a = 4 # maximum ray of the flower
for j in range(2):
ix = range(N*jN*(j+1))
t = np.linspace(j*3.12(j+1)*3.12N) + np.random.randn(N)*0.2 # theta
r = a*np.sin(4*t) + np.random.randn(N)*0.2 # radius
X[ix] = np.c_[r*np.sin(t) r*np.cos(t)]
Y[ix] = j
X = X.T
Y = Y.T
return X Y
def load_extra_datasets():
N = 200
noisy_circles = sklearn.datasets.make_circles(n_samples=N factor=.5 noise=.3)
noisy_moons = sklearn.datasets.make_moons(n_samples=N noise=.2)
blobs = sklearn.datasets.make_blobs(n_samples=N random_state=5 n_features=2 centers=6)
gaussian_quantiles = sklearn.datasets.make_gaussian_quantiles(mean=None cov=0.5 n_samples=N n_features=2 n_classes=2 shuffle=True random_state=None)
no_structure = np.random.rand(N 2) np.random.rand(N 2)
return noisy_circles noisy_moons blobs gaussian_quantiles no_structure
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2253 2018-08-06 14:32 planar_utils.py
文件 3993 2017-10-24 21:01 testCases.py
- 上一篇:非常好的关于光栅投影标定的文章
- 下一篇:利用K2算法学习贝叶斯网络结构
相关资源
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
- 联想启天M4350 BIOS升级文件
- 操作系统教程课后答案华中科技大学
- 用友ERP考试系统练习题库及答案
- 北京邮电大学数据结构历年考研真题
- 真正!!!概率论与数理统计浙江大
- TMS320VC5509A_开发板使用手册
- hxdef100源码、远控、后门
- CentOS-6.7-x86_64-bin-DVD1to2
- 点阵字库显示中英文
- caxa实体设计2019破解补丁
评论
共有 条评论