-
大小: 1.95MB文件类型: .rar金币: 1下载: 0 次发布日期: 2023-09-02
- 语言: 其他
- 标签: dnn_utils_v2
资源简介
这个是深度神经网络的工具类和数据集,里面包括:dnn_utils_v2_lr_utils_dataset
代码片段和文件信息
import numpy as np
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(0 Z)
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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 616958 2017-09-02 17:29 dnn_utils_v2_lr_utils_dataset\cat_datasets\test_catvnoncat.h5
文件 2572022 2017-09-02 17:30 dnn_utils_v2_lr_utils_dataset\cat_datasets\train_catvnoncat.h5
文件 1795 2018-03-31 20:46 dnn_utils_v2_lr_utils_dataset\dnn_utils_v2.py
文件 768 2018-03-31 10:48 dnn_utils_v2_lr_utils_dataset\lr_utils.py
目录 0 2018-03-31 21:52 dnn_utils_v2_lr_utils_dataset\cat_datasets
目录 0 2018-03-31 21:53 dnn_utils_v2_lr_utils_dataset
----------- --------- ---------- ----- ----
3191543 6
评论
共有 条评论