提交 a5b6dfba 编写于 作者: M Mu Li

update links

上级 e4456d3c
......@@ -6,7 +6,7 @@
## 如何贡献
所有notebook是用markdown格式存储,这样方便merge改动。jupyter可以通过notedown来直接使用markdown,[参考这里安装](./chapter00_preface/install.md#使用notedown插件来读写github源文件)
所有notebook是用markdown格式存储,这样方便merge改动。jupyter可以通过notedown来直接使用markdown,[参考这里安装](./chapter_preface/install.md#使用notedown插件来读写github源文件)
build服务器在 http://gluon-ci.mxnet.io 。这台服务器有一块Nvidia M60。
......
......@@ -4,7 +4,7 @@
本教程和接下来几个教程,我们将详细解释如何使用这两个类来定义神经网络、初始化参数、以及保存和读取模型。
我们重新把[多层感知机 --- 使用Gluon](../chapter02_supervised-learning/mlp-gluon.md)里的网络定义搬到这里作为开始的例子(为了简单起见,这里我们丢掉了Flatten层)。
我们重新把[多层感知机 --- 使用Gluon](../chapter_supervised-learning/mlp-gluon.md)里的网络定义搬到这里作为开始的例子(为了简单起见,这里我们丢掉了Flatten层)。
```{.python .input n=9}
from mxnet import nd
......@@ -14,7 +14,7 @@ net = nn.Sequential()
with net.name_scope():
net.add(nn.Dense(256, activation="relu"))
net.add(nn.Dense(10))
print(net)
```
......@@ -86,7 +86,7 @@ print('customized prefix:', net3.dense0.name)
一个简单的实现是这样的:
```{.python .input}
class Sequential(nn.Block):
class Sequential(nn.Block):
def __init__(self, **kwargs):
super(Sequential, self).__init__(**kwargs)
def add(self, block):
......@@ -94,7 +94,7 @@ class Sequential(nn.Block):
def forward(self, x):
for block in self._children:
x = block(x)
return x
return x
```
可以跟`nn.Sequential`一样的使用这个自定义的类:
......@@ -104,7 +104,7 @@ net4 = Sequential()
with net4.name_scope():
net4.add(nn.Dense(256, activation="relu"))
net4.add(nn.Dense(10))
net4.initialize()
y = net4(x)
y
......@@ -149,7 +149,7 @@ class RecMLP(nn.Block):
self.net.add(nn.Dense(256, activation="relu"))
self.net.add(nn.Dense(128, activation="relu"))
self.dense = nn.Dense(64)
def forward(self, x):
return nd.relu(self.dense(self.net(x)))
......
......@@ -108,7 +108,7 @@ $$H = \phi(X W_{wh} + b_h)$$
$$\hat{Y} = \text{softmax}(H W_{hy} + b_y)$$
(跟[多层感知机](../chapter02_multilayer-neural-network/mlp-scratch.md)相比,这里我们把下标从$W_1$和$W_2$改成了意义更加明确的$W_{wh}$和$W_{hy}$)
(跟[多层感知机](../chapter_multilayer-neural-network/mlp-scratch.md)相比,这里我们把下标从$W_1$和$W_2$改成了意义更加明确的$W_{wh}$和$W_{hy}$)
将上面网络改成循环神经网络,我们首先对输入输出加上时间戳$t$。假设$X_t$是序列中的第$t$个输入,对应的隐层输出和最终输出是$H_t$和$\hat{Y}_t$。循环神经网络只需要在计算隐层的输出的时候加上跟前一时间输入的加权和,为此我们引入一个新的可学习的权重$W_{hh}$:
......
# 多层感知机 --- 使用Gluon
我们只需要稍微改动[多类Logistic回归](../chapter01_crashcourse/softmax-regression-gluon.md)来实现多层感知机。
我们只需要稍微改动[多类Logistic回归](../chapter_crashcourse/softmax-regression-gluon.md)来实现多层感知机。
## 定义模型
......
......@@ -16,7 +16,7 @@ train_data, test_data = utils.load_data_fashion_mnist(batch_size)
## 多层感知机
多层感知机与前面介绍的[多类逻辑回归](../chapter01_crashcourse/softmax-regression-scratch.md)非常类似,主要的区别是我们在输入层和输出层之间插入了一到多个隐含层。
多层感知机与前面介绍的[多类逻辑回归](../chapter_crashcourse/softmax-regression-scratch.md)非常类似,主要的区别是我们在输入层和输出层之间插入了一到多个隐含层。
![](../img/multilayer-perceptron.png)
......@@ -103,7 +103,7 @@ for epoch in range(5):
test_acc = utils.evaluate_accuracy(test_data, net)
print("Epoch %d. Loss: %f, Train acc %f, Test acc %f" % (
epoch, train_loss/len(train_data),
epoch, train_loss/len(train_data),
train_acc/len(train_data), test_acc))
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册