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)
layer_sizes

相关文章:

  • 2021-06-30
  • 2021-12-13
  • 2022-02-06
  • 2021-07-31
  • 2021-09-04
  • 2021-07-12
  • 2021-11-16
猜你喜欢
  • 2021-10-04
  • 2022-01-03
  • 2021-09-10
  • 2021-11-25
  • 2022-01-15
  • 2021-12-22
  • 2021-11-27
相关资源
相似解决方案