随笔分类 - language:Python
摘要:1. 深层神经网络(Deep L-layer neural network ) 2. 前向传播和反向传播(Forward and backward propagation) 3. 总结 4. 深层网络中的前向传播(Forward propagation in a Deep Network) 向量化实
阅读全文
摘要:# Print accuracy predictions = predict(parameters, X) # (np.dot(Y, predictions.T) + np.dot(1 - Y, 1 - predictions.T)) / Y.size print ("Accuracy: {} %".format(100 - np.mean(abs(predictions - Y)) * 10...
阅读全文
摘要:1. 线性代数中矩阵乘法: np.dot() 1. 线性代数中矩阵乘法: np.dot() 1. 线性代数中矩阵乘法: np.dot() import numpy as np # 2 x 3 matrix1 = np.array([[1, 2, 3], [4, 5, 6]]) # 3 x 2
阅读全文
摘要: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 i...
阅读全文
摘要:contour和contourf 绘制三维图 其中前两个参数x和y:两个等长一维数组 第三个参数z: 二维数组(表示平面点xi, yi映射的函数值)。 由于contourf可以填充等高线之间的空隙颜色,呈现出区域的分划状,所以很多分类机器学习模型的可视化常会借助其展现。 参考:https://blo
阅读全文
摘要:np.c_给numpy数组添加列 np.r_给numpy数组添加行 ravel(): 将多维数组降成一维, 返回的是视图
阅读全文
摘要:Y改成Y.reshape(400)
阅读全文
摘要:Planar data classification with one hidden layer 你会学习到如何: 用单隐层实现一个二分类神经网络 使用一个非线性激励函数,如 tanh 计算交叉熵的损失值 实现前向传播和后向传播 1 - Packages(导入包) 需要导入的包: numpy:Pyt
阅读全文
摘要:我们使用(keepdims = True)来确保 A.shape 是(4,1)而不是(4,),它使我们的代码更加严格。容易减少深度学习中代码bug
阅读全文
摘要:rates = [0.01, 0.001, 0.0001] models = {} costs = np.array([[0.7, 0.9, 0.4, 0.6, 0.4, 0.3, 0.2, 0.1], [0.7, 0.65, 0.64, 0.63, 0.62, 0.61, 0.60, 0.59], [0.7, 0.6,...
阅读全文
摘要:import numpy as np x = np.array([[[0], [1], [2]]]) print(x.shape) d = np.squeeze(x) # 从数组的形状中删除单维条目,即把shape中为1的维度去掉 print(d.shape)
阅读全文
摘要:一、map/reduce map map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次 作用到序列的每个元素,并把结果作为新的Iterator返回。 reduce reduce把 结果 继续 和序列 的 下一个元素 做 累积计算 str > int filter()
阅读全文
摘要:问题 1:在函数内部,针对参数使用 赋值语句,会不会影响调用函数时传递的 实参变量? —— 不会! 无论传递的参数是 可变 还是 不可变 只要 针对参数 使用 赋值语句,会在 函数内部 修改 局部变量的引用,不会影响到 外部变量的引用 问题 2:如果传递的参数是 可变类型,在函数内部,使用 方法 修
阅读全文
摘要:02. 可变和不可变类型 不可变类型,内存中的数据不允许被修改: 数字类型 int , bool , float , complex , long(2.x) 字符串 str 元组 tuple 可变类型,内存中的数据可以被修改: 列表 list 字典 dict 不可变类型,内存中的数据不允许被修改:
阅读全文
摘要:目标 列表元组 字典 字符串 公共方法 变量高级 01. 列表 02. 元组 03. 字典 04. 字符串 1)判断类型 - 9 2) 查找和替换 - 7 3) 大小写转换 - 5 4) 文本对齐 - 3 5) 去除空白字符 - 3 6) 拆分和连接 - 5 5.1 Python 内置函数 5.3
阅读全文
摘要:读入的数据是:福尔摩斯探案,6mb这样...... 输出NWORDS:
阅读全文
摘要:以下均为自己看视频做的笔记,自用,侵删! (p(h): 先验概率) 贝叶斯拼写检查器实现 In [1]: import re, collections def words(text): return re.findall('[a-z]+', text.lower()) def train(featu
阅读全文
摘要:import random import urllib from urllib import request import os ######################################################### # 参数设置 wsp = 'DouziOOXX' # 打开连接 def url_open(url): req = urllib.reques...
阅读全文
摘要:论一只爬虫的自我修养 URL的一般格式(带括号[]的为可选项): protocol://hostname[:port]/path/[;parameters][?query]#fragment URL由三部分组成: 第一部分是协议: http、https、ftp、file、ed2k.... 第二部分是
阅读全文

浙公网安备 33010602011771号