Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
6f24e96b
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6f24e96b
编写于
3月 23, 2020
作者:
L
Li Fuchen
提交者:
GitHub
3月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change fluid.layers.embedding to fluid.embedding to fix a bug of dim (#847)
上级
358cd5d3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
11 addition
and
14 deletion
+11
-14
06.understand_sentiment/README.cn.md
06.understand_sentiment/README.cn.md
+2
-2
06.understand_sentiment/README.md
06.understand_sentiment/README.md
+2
-2
06.understand_sentiment/index.cn.html
06.understand_sentiment/index.cn.html
+2
-2
06.understand_sentiment/index.html
06.understand_sentiment/index.html
+2
-2
06.understand_sentiment/train_conv.py
06.understand_sentiment/train_conv.py
+1
-2
06.understand_sentiment/train_dyn_rnn.py
06.understand_sentiment/train_dyn_rnn.py
+1
-2
06.understand_sentiment/train_stacked_lstm.py
06.understand_sentiment/train_stacked_lstm.py
+1
-2
未找到文件。
06.understand_sentiment/README.cn.md
浏览文件 @
6f24e96b
...
@@ -151,7 +151,7 @@ BATCH_SIZE = 128 #batch的大小
...
@@ -151,7 +151,7 @@ BATCH_SIZE = 128 #batch的大小
```
python
```
python
#文本卷积神经网络
#文本卷积神经网络
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
input
=
emb
,
input
=
emb
,
...
@@ -183,7 +183,7 @@ def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
...
@@ -183,7 +183,7 @@ def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
#计算词向量
#计算词向量
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
#第一层栈
#第一层栈
...
...
06.understand_sentiment/README.md
浏览文件 @
6f24e96b
...
@@ -140,7 +140,7 @@ Note that `fluid.nets.sequence_conv_pool` contains both convolution and pooling
...
@@ -140,7 +140,7 @@ Note that `fluid.nets.sequence_conv_pool` contains both convolution and pooling
```
python
```
python
#Textconvolution neural network
#Textconvolution neural network
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
input
=
emb
,
input
=
emb
,
...
@@ -172,7 +172,7 @@ The code of the stack bidirectional LSTM `stacked_lstm_net` is as follows:
...
@@ -172,7 +172,7 @@ The code of the stack bidirectional LSTM `stacked_lstm_net` is as follows:
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
# Calculate word vectorvector
# Calculate word vectorvector
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
#First stack
#First stack
...
...
06.understand_sentiment/index.cn.html
浏览文件 @
6f24e96b
...
@@ -193,7 +193,7 @@ BATCH_SIZE = 128 #batch的大小
...
@@ -193,7 +193,7 @@ BATCH_SIZE = 128 #batch的大小
```python
```python
#文本卷积神经网络
#文本卷积神经网络
def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
emb = fluid.
layers.
embedding(
emb = fluid.embedding(
input=data, size=[input_dim, emb_dim], is_sparse=True)
input=data, size=[input_dim, emb_dim], is_sparse=True)
conv_3 = fluid.nets.sequence_conv_pool(
conv_3 = fluid.nets.sequence_conv_pool(
input=emb,
input=emb,
...
@@ -225,7 +225,7 @@ def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
...
@@ -225,7 +225,7 @@ def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
def stacked_lstm_net(data, input_dim, class_dim, emb_dim, hid_dim, stacked_num):
def stacked_lstm_net(data, input_dim, class_dim, emb_dim, hid_dim, stacked_num):
#计算词向量
#计算词向量
emb = fluid.
layers.
embedding(
emb = fluid.embedding(
input=data, size=[input_dim, emb_dim], is_sparse=True)
input=data, size=[input_dim, emb_dim], is_sparse=True)
#第一层栈
#第一层栈
...
...
06.understand_sentiment/index.html
浏览文件 @
6f24e96b
...
@@ -182,7 +182,7 @@ Note that `fluid.nets.sequence_conv_pool` contains both convolution and pooling
...
@@ -182,7 +182,7 @@ Note that `fluid.nets.sequence_conv_pool` contains both convolution and pooling
```python
```python
#Textconvolution neural network
#Textconvolution neural network
def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim):
emb = fluid.
layers.
embedding(
emb = fluid.embedding(
input=data, size=[input_dim, emb_dim], is_sparse=True)
input=data, size=[input_dim, emb_dim], is_sparse=True)
conv_3 = fluid.nets.sequence_conv_pool(
conv_3 = fluid.nets.sequence_conv_pool(
input=emb,
input=emb,
...
@@ -214,7 +214,7 @@ The code of the stack bidirectional LSTM `stacked_lstm_net` is as follows:
...
@@ -214,7 +214,7 @@ The code of the stack bidirectional LSTM `stacked_lstm_net` is as follows:
def stacked_lstm_net(data, input_dim, class_dim, emb_dim, hid_dim, stacked_num):
def stacked_lstm_net(data, input_dim, class_dim, emb_dim, hid_dim, stacked_num):
# Calculate word vectorvector
# Calculate word vectorvector
emb = fluid.
layers.
embedding(
emb = fluid.embedding(
input=data, size=[input_dim, emb_dim], is_sparse=True)
input=data, size=[input_dim, emb_dim], is_sparse=True)
#First stack
#First stack
...
...
06.understand_sentiment/train_conv.py
浏览文件 @
6f24e96b
...
@@ -42,8 +42,7 @@ def parse_args():
...
@@ -42,8 +42,7 @@ def parse_args():
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
def
convolution_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
):
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
conv_3
=
fluid
.
nets
.
sequence_conv_pool
(
input
=
emb
,
input
=
emb
,
num_filters
=
hid_dim
,
num_filters
=
hid_dim
,
...
...
06.understand_sentiment/train_dyn_rnn.py
浏览文件 @
6f24e96b
...
@@ -42,8 +42,7 @@ def parse_args():
...
@@ -42,8 +42,7 @@ def parse_args():
def
dynamic_rnn_lstm
(
data
,
input_dim
,
class_dim
,
emb_dim
,
lstm_size
):
def
dynamic_rnn_lstm
(
data
,
input_dim
,
class_dim
,
emb_dim
,
lstm_size
):
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
sentence
=
fluid
.
layers
.
fc
(
input
=
emb
,
size
=
lstm_size
*
4
,
act
=
'tanh'
)
sentence
=
fluid
.
layers
.
fc
(
input
=
emb
,
size
=
lstm_size
*
4
,
act
=
'tanh'
)
lstm
,
_
=
fluid
.
layers
.
dynamic_lstm
(
sentence
,
size
=
lstm_size
*
4
)
lstm
,
_
=
fluid
.
layers
.
dynamic_lstm
(
sentence
,
size
=
lstm_size
*
4
)
...
...
06.understand_sentiment/train_stacked_lstm.py
浏览文件 @
6f24e96b
...
@@ -46,8 +46,7 @@ def parse_args():
...
@@ -46,8 +46,7 @@ def parse_args():
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
def
stacked_lstm_net
(
data
,
input_dim
,
class_dim
,
emb_dim
,
hid_dim
,
stacked_num
):
assert
stacked_num
%
2
==
1
assert
stacked_num
%
2
==
1
emb
=
fluid
.
layers
.
embedding
(
emb
=
fluid
.
embedding
(
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
input
=
data
,
size
=
[
input_dim
,
emb_dim
],
is_sparse
=
True
)
fc1
=
fluid
.
layers
.
fc
(
input
=
emb
,
size
=
hid_dim
)
fc1
=
fluid
.
layers
.
fc
(
input
=
emb
,
size
=
hid_dim
)
lstm1
,
cell1
=
fluid
.
layers
.
dynamic_lstm
(
input
=
fc1
,
size
=
hid_dim
)
lstm1
,
cell1
=
fluid
.
layers
.
dynamic_lstm
(
input
=
fc1
,
size
=
hid_dim
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录