mirror of
https://github.com/openmlsys/openmlsys-zh.git
synced 2026-04-02 02:10:12 +08:00
fix typos in chapter 2 (#211)
This commit is contained in:
@@ -80,7 +80,7 @@ output = convolution(input, conv1_filters, stride=1, padding='same')
|
||||
output = pooling(output, kernel_size=3, stride=2, padding='same', mode='max')
|
||||
output = convolution(output, conv2_filters, stride=1, padding='same')
|
||||
output = pooling(output, kernel_size=3, stride=2, padding='same', mode='max')
|
||||
output=flatten(output)
|
||||
output = flatten(output)
|
||||
output = fully_connected(output, fc1_weights)
|
||||
output = fully_connected(output, fc2_weights)
|
||||
output = fully_connected(output, fc3_weights)
|
||||
@@ -107,7 +107,7 @@ PyTorch提供的torch.nn.Module、torch.nn.Conv2d、torch.utils.data.Dataset。
|
||||
Cell和Module是模型抽象方法也是所有网络的基类。
|
||||
现有模型抽象方案有两种。
|
||||
一种是抽象出两个方法分别为Layer(负责单个神经网络层的参数构建和前向计算),Model(负责对神经网络层进行连接组合和神经网络层参数管理);
|
||||
另一种是将Layer和Modle抽象成一个方法,该方法既能表示单层神经网络层也能表示包含多个神经网络层堆叠的模型,Cell和Module就是这样实现的。
|
||||
另一种是将Layer和Model抽象成一个方法,该方法既能表示单层神经网络层也能表示包含多个神经网络层堆叠的模型,Cell和Module就是这样实现的。
|
||||
|
||||

|
||||
:width:`800px`
|
||||
@@ -127,7 +127,7 @@ Cell和Module是模型抽象方法也是所有网络的基类。
|
||||
|
||||
```python
|
||||
# 接口定义:
|
||||
全连接层接口:convolution(input, filters, stride, padding)
|
||||
卷积层的接口:convolution(input, filters, stride, padding)
|
||||
变量:Variable(value, trainable=True)
|
||||
高斯分布初始化方法:random_normal(shape)
|
||||
神经网络模型抽象方法:Cell
|
||||
@@ -189,5 +189,5 @@ class CNN(Cell):
|
||||
return z
|
||||
net = CNN()
|
||||
```
|
||||
|
||||
|
||||
上述卷积模型进行实例化,其执行将从\_\_init\_\_开始,第一个是Conv2D,Conv2D也是Cell的子类,会进入到Conv2D的\_\_init\_\_,此时会将第一个Conv2D的卷积参数收集到self.\_params,之后回到Conv2D,将第一个Conv2D收集到self.\_cells;第二个的组件是MaxPool2D,因为其没有训练参数,因此将MaxPool2D收集到self.\_cells;依次类推,分别收集第二个卷积参数和卷积层,三个全连接层的参数和全连接层。实例化之后可以调用net.parameters_and_names来返回训练参数;调用net.cells_and_names查看神经网络层列表。
|
||||
|
||||
Reference in New Issue
Block a user