1、本次搭建的神经网络模型具有一个隐藏层的二分类
2、需要的激活函数有tanh,sigmoid
3、用了正向传播和反向传播。
4、计算交叉熵损失。
模型如下:
用到的数学公式:
1、定义神经网络结构(比如输入单元、隐藏单元等等)
2、初始化模型的参数
3、循环(迭代次数):
⑴实现向前传播
⑵计算损失
⑶实现向后传播以获得渐变
⑷更新参数(梯度下降)
1、定义神经网络结构
本次设置隐藏层大小为4
n_x:输入层的大小。
n_h:隐藏层的大小(将其设置为4)
n_y:输出层的大小。
1 def layer_sizes(X, Y): 2 """ 3 Arguments: 4 X -- input dataset of shape (input size, number of examples) 5 Y -- labels of shape (output size, number of examples) 6 7 Returns: 8 n_x -- the size of the input layer 9 n_h -- the size of the hidden layer 10 n_y -- the size of the output layer 11 """ 12 ### START CODE HERE ### (≈ 3 lines of code) 13 n_x = X.shape[0] # size of input layer 14 n_h = 4 15 n_y = Y.shape[0] # size of output layer 16 ### END CODE HERE ### 17 return (n_x, n_h, n_y)