吴恩达深度学习deeplearning第五课第一周课后测验及编程作业含答案


吴恩达深度学习deeplearning第五课第一周课后测验及编程作业(含答案)
资源截图
代码片段和文件信息
import numpy as np

def softmax(x):
    e_x = np.exp(x - np.max(x))
    return e_x / e_x.sum(axis=0)


def sigmoid(x):
    return 1 / (1 + np.exp(-x))


def initialize_adam(parameters) :
    “““
    Initializes v and s as two python dictionaries with:
                - keys: “dW1“ “db1“ ... “dWL“ “dbL“ 
                - values: numpy arrays of zeros of the same shape as the corresponding gradients/parameters.
    
    Arguments:
    parameters -- python dictionary containing your parameters.
                    parameters[“W“ + str(l)] = Wl
                    parameters[“b“ + str(l)] = bl
    
    Returns: 
    v -- python dictionary that will contain the exponentially weighted average of the gradient.
                    v[“dW“ + str(l)] = ...
                    v[“db“ + str(l)] = ...
    s -- python dictionary that will contain the exponentially weighted average of the squared gradient.
                    s[“dW“ + str(l)] = ...
                    s[“db“ + str(l)] = ...

    “““
    
    L = len(parameters) // 2 # number of layers in the neural networks
    v = {}
    s = {}
    
    # Initialize v s. Input: “parameters“. Outputs: “v s“.
    for l in range(L):
    ### START CODE HERE ### (approx. 4 lines)
        v[“dW“ + str(l+1)] = np.zeros(parameters[“W“ + str(l+1)].shape)
        v[“db“ + str(l+1)] = np.zeros(parameters[“b“ + str(l+1)].shape)
        s[“dW“ + str(l+1)] = np.zeros(parameters[“W“ + str(l+1)].shape)
        s[“db“ + str(l+1)] = np.zeros(parameters[“b“ + str(l+1)].shape)
    ### END CODE HERE ###
    
    return v s


def update_parameters_with_adam(parameters grads v s t learning_rate = 0.01
                                beta1 = 0.9 beta2 = 0.999  epsilon = 1e-8):
    “““
    Update parameters using Adam
    
    Arguments:
    parameters -- python dictionary containing your parameters:
                    parameters[‘W‘ + str(l)] = Wl
                    parameters[‘b‘ + str(l)] = bl
    grads -- python dictionary containing your gradients for each parameters:
                    grads[‘dW‘ + str(l)] = dWl
                    grads[‘db‘ + str(l)] = dbl
    v -- Adam variable moving average of the first gradient python dictionary
    s -- Adam variable moving average of the squared gradient python dictionary
    learning_rate -- the learning rate scalar.
    beta1 -- Exponential decay hyperparameter for the first moment estimates 
    beta2 -- Exponential decay hyperparameter for the second moment estimates 
    epsilon -- hyperparameter preventing division by zero in Adam updates

    Returns:
    parameters -- python dictionary containing your updated parameters 
    v -- Adam variable moving average of the first gradient python dictionary
    s -- Adam variable moving average of the squared gradient python dictionary
    “““
    
    L = len(parameters) // 2                 # number of layers in the neural networks
    v_corrected = {}                         # Initializing first moment estimat

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-02-20 21:33  5.1 循环序列模型
     目录           0  2018-03-02 00:33  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step
     目录           0  2018-02-25 14:21  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step.ipynb_checkpoints
     文件       86391  2018-03-02 00:33  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step.ipynb_checkpointsBuilding a Recurrent Neural Network-Step by Step-v3-checkpoint.ipynb
     目录           0  2018-02-25 14:44  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step\__pycache__
     文件        3910  2018-02-25 14:44  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step\__pycache__
nn_utils.cpython-36.pyc
     文件       78502  2018-02-20 20:59  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepBuilding a Recurrent Neural Network-Step by Step-v1.ipynb
     文件       78518  2018-02-20 20:59  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepBuilding a Recurrent Neural Network-Step by Step-v2.ipynb
     文件       86391  2018-03-02 00:33  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepBuilding a Recurrent Neural Network-Step by Step-v3.ipynb
     目录           0  2018-02-20 21:04  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepdata
     文件      312514  2018-02-20 21:03  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepdatainput.txt
     目录           0  2018-02-20 21:07  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepimages
     文件      143266  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepimagesinitial_state.png
     文件      193213  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepimagesLSTM.png
     文件       85971  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepimagesLSTM_rnn.png
     文件       95689  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepimages
nn (1).png
     文件       59480  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by StepimagesRNN.png
     文件      149330  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepimages
nn_cell_backprop.png
     文件      142063  2018-02-20 21:06  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepimages
nn_step_forward.png
     文件        5155  2018-02-20 21:00  5.1 循环序列模型Building a Recurrent Neural Network -Step by Step
nn_utils.py
     文件       94630  2018-02-20 21:00  5.1 循环序列模型Building a Recurrent Neural Network -Step by Stepshakespeare.txt
     文件        4446  2018-02-20 21:00  5.1 循环序列模型Building a Recurrent Neural Network -Step by Steputils.py
     目录           0  2018-03-04 18:56  5.1 循环序列模型Dinosaur lsland --Character -level language model
     目录           0  2018-03-02 14:20  5.1 循环序列模型Dinosaur lsland --Character -level language model.ipynb_checkpoints
     文件       38357  2018-03-02 14:20  5.1 循环序列模型Dinosaur lsland --Character -level language model.ipynb_checkpointsDinosaurus Island--Character level language model final-v3-checkpoint.ipynb
     目录           0  2018-03-02 16:25  5.1 循环序列模型Dinosaur lsland --Character -level language model\__pycache__
     文件        4088  2018-03-02 16:25  5.1 循环序列模型Dinosaur lsland --Character -level language model\__pycache__shakespeare_utils.cpython-36.pyc
     文件        4205  2018-03-02 14:30  5.1 循环序列模型Dinosaur lsland --Character -level language model\__pycache__utils.cpython-36.pyc
     文件       19909  2018-02-20 21:11  5.1 循环序列模型Dinosaur lsland --Character -level language modeldinos.txt
     文件       37753  2018-02-20 21:11  5.1 循环序列模型Dinosaur lsland --Character -level language modelDinosaurus Island--Character level language model final-v1.ipynb
     文件       37891  2018-02-20 21:11  5.1 循环序列模型Dinosaur lsland --Character -level language modelDinosaurus Island--Character level language model final-v2-Copy1.ipynb
............此处省略49个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)