Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
16075ce2
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
16075ce2
编写于
9月 14, 2017
作者:
R
ranqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code style
上级
ee46d363
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
9 addition
and
9 deletion
+9
-9
mt_with_external_memory/model.py
mt_with_external_memory/model.py
+9
-9
未找到文件。
mt_with_external_memory/model.py
浏览文件 @
16075ce2
...
...
@@ -126,14 +126,14 @@ def memory_enhanced_decoder(input, target, initial_state, source_context, size,
],
act
=
paddle
.
activation
.
Linear
())
bounded_memory_weight_init
=
paddle
.
layer
.
slope_intercept
(
input
=
paddle
.
layer
.
fc
(
input
=
bounded_memory_init
,
size
=
1
),
slope
=
0.0
,
intercept
=
0.0
)
input
=
paddle
.
layer
.
fc
(
input
=
bounded_memory_init
,
size
=
1
),
slope
=
0.0
,
intercept
=
0.0
)
unbounded_memory_init
=
source_context
unbounded_memory_weight_init
=
paddle
.
layer
.
slope_intercept
(
input
=
paddle
.
layer
.
fc
(
input
=
unbounded_memory_init
,
size
=
1
),
slope
=
0.0
,
intercept
=
0.0
)
input
=
paddle
.
layer
.
fc
(
input
=
unbounded_memory_init
,
size
=
1
),
slope
=
0.0
,
intercept
=
0.0
)
# prepare step function for reccurent group
def
recurrent_decoder_step
(
cur_embedding
):
...
...
@@ -144,14 +144,14 @@ def memory_enhanced_decoder(input, target, initial_state, source_context, size,
name
=
"bounded_memory"
,
mem_slot_size
=
size
,
boot_layer
=
bounded_memory_init
,
initial_weight
=
bounded_memory_weight_init
,
initial_weight
=
bounded_memory_weight_init
,
readonly
=
False
,
enable_interpolation
=
True
)
unbounded_memory
=
ExternalMemory
(
name
=
"unbounded_memory"
,
mem_slot_size
=
size
*
2
,
boot_layer
=
unbounded_memory_init
,
initial_weight
=
unbounded_memory_weight_init
,
initial_weight
=
unbounded_memory_weight_init
,
readonly
=
True
,
enable_interpolation
=
False
)
# write bounded memory
...
...
@@ -164,7 +164,7 @@ def memory_enhanced_decoder(input, target, initial_state, source_context, size,
size
=
size
,
act
=
paddle
.
activation
.
Tanh
(),
bias_attr
=
False
)
# read unbounded memory (i.e. attention mechanism)
# read unbounded memory (i.e. attention mechanism)
context
=
unbounded_memory
.
read
(
key_for_unbounded_memory
)
# gated recurrent unit
gru_inputs
=
paddle
.
layer
.
fc
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录