Skip to content

Commit

Permalink
revise parameters (d2l-ai#334)
Browse files Browse the repository at this point in the history
* GAN PiC

* Revise para
  • Loading branch information
rongruosong authored and astonzhang committed Aug 21, 2018
1 parent 1b392b0 commit 84bf649
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions chapter_natural-language-processing/sentiment-analysis-cnn.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ glove_embedding = text.embedding.create(
```{.python .input n=10}
class TextCNN(nn.Block):
def __init__(self, vocab, embedding_size, ngram_kernel_sizes,
nums_channels, **kwargs):
nums_channels, num_outputs, **kwargs):
super(TextCNN, self).__init__(**kwargs)
self.ngram_kernel_sizes = ngram_kernel_sizes
self.embedding_static = nn.Embedding(len(vocab), embedding_size)
Expand Down Expand Up @@ -215,7 +215,7 @@ ctx = gb.try_all_gpus()
接下来,我们用预训练的100维GloVe词向量初始化`embedding_static``embedding_non_static`。其中只有`embedding_static`在训练中不更新模型参数。

```{.python .input}
net = TextCNN(vocab, embed_size, ngram_kernel_sizes, nums_channels)
net = TextCNN(vocab, embed_size, ngram_kernel_sizes, nums_channels, num_outputs)
net.initialize(init.Xavier(), ctx=ctx)
# embedding_static 和 embedding_non_static 均使用预训练的词向量。
net.embedding_static.weight.set_data(glove_embedding.idx_to_vec)
Expand Down
4 changes: 2 additions & 2 deletions chapter_natural-language-processing/sentiment-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ glove_embedding = text.embedding.create(
```{.python .input n=10}
class BiRNN(nn.Block):
def __init__(self, vocab, embed_size, num_hiddens, num_layers,
bidirectional, **kwargs):
bidirectional, num_outputs, **kwargs):
super(BiRNN, self).__init__(**kwargs)
self.embedding = nn.Embedding(len(vocab), embed_size)
self.encoder = rnn.LSTM(num_hiddens, num_layers=num_layers,
Expand Down Expand Up @@ -199,7 +199,7 @@ num_layers = 2
bidirectional = True
ctx = gb.try_all_gpus()
net = BiRNN(vocab, embed_size, num_hiddens, num_layers, bidirectional)
net = BiRNN(vocab, embed_size, num_hiddens, num_layers, bidirectional, num_outputs)
net.initialize(init.Xavier(), ctx=ctx)
# 设置 embedding 层的 weight 为预训练的词向量。
net.embedding.weight.set_data(glove_embedding.idx_to_vec)
Expand Down
Binary file modified contrib/img/DCGAN.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 84bf649

Please sign in to comment.