资源简介
coursera的吴恩达的课编程练习所需的所需包和数据,可以方便学员自己在本地练习
代码片段和文件信息
import numpy as np
import matplotlib.pyplot as plt
import h5py
def sigmoid(Z):
“““
Implements the sigmoid activation in numpy
Arguments:
Z -- numpy array of any shape
Returns:
A -- output of sigmoid(z) same shape as Z
cache -- returns Z as well useful during backpropagation
“““
A = 1/(1+np.exp(-Z))
cache = Z
return A cache
def relu(Z):
“““
Implement the RELU function.
Arguments:
Z -- Output of the linear layer of any shape
Returns:
A -- Post-activation parameter of the same shape as Z
cache -- a python dictionary containing “A“ ; stored for computing the backward pass efficiently
“““
A = np.maximum(0Z)
assert(A.shape == Z.shape)
cache = Z
return A cache
def relu_backward(dA cache):
“““
Implement the backward propagation for a single RELU unit.
Arguments:
dA -- post-activation gradient of any shape
cache -- ‘Z‘ where we store for computing backward propagation efficiently
Returns:
dZ -- Gradient of the cost with respect to Z
“““
Z = cache
dZ = np.array(dA copy=True) # just converting dz to a correct object.
# When z <= 0 you should set dz to 0 as well.
dZ[Z <= 0] = 0
assert (dZ.shape == Z.shape)
return dZ
def sigmoid_backward(dA cache):
“““
Implement the backward propagation for a single SIGMOID unit.
Arguments:
dA -- post-activation gradient of any shape
cache -- ‘Z‘ where we store for computing backward propagation efficiently
Returns:
dZ -- Gradient of the cost with respect to Z
“““
Z = cache
s = 1/(1+np.exp(-Z))
dZ = dA * s * (1-s)
assert (dZ.shape == Z.shape)
return dZ
def load_data():
train_dataset = h5py.File(‘datasets/train_catvnoncat.h5‘ “r“)
train_set_x_orig = np.array(train_dataset[“train_set_x“][:]) # your train set features
train_set_y_orig = np.array(train_dataset[“train_set_y“][:]) # your train set labels
test_dataset = h5py.File(‘datasets/test_catvnoncat.h5‘ “r“)
test_set_x_orig = np.array(test_dataset[“test_set_x“][:]) # your test set features
test_set_y_orig = np.array(test_dataset[“test_set_y“][:]) # your test set labels
classes = np.array(test_dataset[“list_classes“][:]) # the list of classes
train_set_y_orig = train_set_y_orig.reshape((1 train_set_y_orig.shape[0]))
test_set_y_orig = test_set_y_orig.reshape((1 test_set_y_orig.shape[0]))
return train_set_x_orig train_set_y_orig test_set_x_orig test_set_y_orig classes
def initialize_parameters(n_x n_h n_y):
“““
Argument:
n_x -- size of the input layer
n_h -- size of the hidden layer
n_y -- size of the output layer
Returns:
parameters -- python dictionary containing your parameters:
W1 -- weight matrix of shape (n_h n_x)
b1 -- bias vector of shape
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-27 19:55 datasets\
文件 2572022 2017-08-27 19:55 datasets\train_catvnoncat.h5
文件 616958 2017-08-27 19:55 datasets\test_catvnoncat.h5
文件 14776 2017-08-27 19:55 dnn_app_utils_v2.py
相关资源
- Coursera machine learning答案
- 吴恩达机器学习coursera作业题目+答案
- coursera机器学习课后习题答案全套
- coursera北京大学操作系统课件
- coursera斯坦福Andrew Ng机器学习编程作业
- Coursera课程Deeplearning深度学习笔记+课
- 数字手势数据集Coursera - Deep Learning
- Coursera吴恩达机器学习课程PPT合集纯净
- coursera上的《machine learning》的所有大
- coursera机器学习吴恩达编程作业答案全
- coursera吴恩达机器学习第一到第六周
- R programming WEEK4
- 吴恩达coursera机器学习吴恩达全套视频
- coursera斯坦福机器学习公开课支持向量
- coursera吴恩达机器学习讲义pdf
- coursera吴恩达机器学习全套教学视频
- Coursera Machine Learning 第二周编程全套满
- coursera 吴恩达深度机器学习 deep lear
- 百度网盘链接coursera 吴恩达深度机器
- coursera吴恩达机器学习全套视频和文档
-
coursera Hadoop Platform and Application fr
- 最新版coursera吴恩达机器学习全套视频
- Coursera吴恩达机器学习课程第二周编程
- 斯坦福大学吴恩达Coursera机器学习公开
- 完整视频-coursera公开课 普林斯顿算法
评论
共有 条评论