a Neural Network with a single hidden layer (具有单个隐藏层的神经网络)

a Neural Network with a single hidden layer (具有单个隐藏层的神经网络)_第1张图片

a Neural Network with a single hidden layer (具有单个隐藏层的神经网络)_第2张图片

(you can use either np.multiply() and then np.sum() or directly np.dot()).
Note that if you use np.multiply followed by np.sum the end result will be a type float, whereas if you use np.dot, the result will be a 2D numpy array. We can use np.squeeze() to remove redundant dimensions (in the case of single float, this will be reduced to a zero-dimension array). We can cast the array as a type float using float().

logprobs = np.multiply(np.log(A2),Y)
cost = - np.sum(logprobs)   

a Neural Network with a single hidden layer (具有单个隐藏层的神经网络)_第3张图片

a Neural Network with a single hidden layer (具有单个隐藏层的神经网络)_第4张图片

你可能感兴趣的:(深度学习)