Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
hapi
提交
c8d2dff9
H
hapi
项目概览
PaddlePaddle
/
hapi
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hapi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c8d2dff9
编写于
9月 10, 2020
作者:
Q
qingqing01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change fluid.dygraph.Layer to paddle.nn.Layer
上级
080748fc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
8 addition
and
7 deletion
+8
-7
examples/ocr/seq2seq_attn.py
examples/ocr/seq2seq_attn.py
+8
-7
未找到文件。
examples/ocr/seq2seq_attn.py
浏览文件 @
c8d2dff9
...
@@ -15,6 +15,7 @@ from __future__ import print_function
...
@@ -15,6 +15,7 @@ from __future__ import print_function
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.fluid.layers
as
layers
import
paddle.fluid.layers
as
layers
from
paddle.fluid.layers
import
BeamSearchDecoder
from
paddle.fluid.layers
import
BeamSearchDecoder
...
@@ -22,7 +23,7 @@ from paddle.fluid.layers import BeamSearchDecoder
...
@@ -22,7 +23,7 @@ from paddle.fluid.layers import BeamSearchDecoder
from
paddle.text
import
RNNCell
,
RNN
,
DynamicDecode
from
paddle.text
import
RNNCell
,
RNN
,
DynamicDecode
class
ConvBNPool
(
fluid
.
dygraph
.
Layer
):
class
ConvBNPool
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
def
__init__
(
self
,
in_ch
,
in_ch
,
out_ch
,
out_ch
,
...
@@ -81,7 +82,7 @@ class ConvBNPool(fluid.dygraph.Layer):
...
@@ -81,7 +82,7 @@ class ConvBNPool(fluid.dygraph.Layer):
return
out
return
out
class
CNN
(
fluid
.
dygraph
.
Layer
):
class
CNN
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
in_ch
=
1
,
is_test
=
False
):
def
__init__
(
self
,
in_ch
=
1
,
is_test
=
False
):
super
(
CNN
,
self
).
__init__
()
super
(
CNN
,
self
).
__init__
()
self
.
conv_bn1
=
ConvBNPool
(
in_ch
,
16
)
self
.
conv_bn1
=
ConvBNPool
(
in_ch
,
16
)
...
@@ -134,7 +135,7 @@ class GRUCell(RNNCell):
...
@@ -134,7 +135,7 @@ class GRUCell(RNNCell):
return
[
self
.
hidden_size
]
return
[
self
.
hidden_size
]
class
Encoder
(
fluid
.
dygraph
.
Layer
):
class
Encoder
(
paddle
.
nn
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
in_channel
=
1
,
in_channel
=
1
,
...
@@ -185,7 +186,7 @@ class Encoder(fluid.dygraph.Layer):
...
@@ -185,7 +186,7 @@ class Encoder(fluid.dygraph.Layer):
return
gru_bwd
,
encoded_vector
,
encoded_proj
return
gru_bwd
,
encoded_vector
,
encoded_proj
class
Attention
(
fluid
.
dygraph
.
Layer
):
class
Attention
(
paddle
.
nn
.
Layer
):
"""
"""
Neural Machine Translation by Jointly Learning to Align and Translate.
Neural Machine Translation by Jointly Learning to Align and Translate.
https://arxiv.org/abs/1409.0473
https://arxiv.org/abs/1409.0473
...
@@ -230,7 +231,7 @@ class DecoderCell(RNNCell):
...
@@ -230,7 +231,7 @@ class DecoderCell(RNNCell):
return
hidden
,
hidden
return
hidden
,
hidden
class
Decoder
(
fluid
.
dygraph
.
Layer
):
class
Decoder
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
num_classes
,
emb_dim
,
encoder_size
,
decoder_size
):
def
__init__
(
self
,
num_classes
,
emb_dim
,
encoder_size
,
decoder_size
):
super
(
Decoder
,
self
).
__init__
()
super
(
Decoder
,
self
).
__init__
()
self
.
decoder_attention
=
RNN
(
DecoderCell
(
encoder_size
,
decoder_size
))
self
.
decoder_attention
=
RNN
(
DecoderCell
(
encoder_size
,
decoder_size
))
...
@@ -247,7 +248,7 @@ class Decoder(fluid.dygraph.Layer):
...
@@ -247,7 +248,7 @@ class Decoder(fluid.dygraph.Layer):
return
pred
return
pred
class
Seq2SeqAttModel
(
fluid
.
dygraph
.
Layer
):
class
Seq2SeqAttModel
(
paddle
.
nn
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
in_channle
=
1
,
in_channle
=
1
,
...
@@ -320,7 +321,7 @@ class Seq2SeqAttInferModel(Seq2SeqAttModel):
...
@@ -320,7 +321,7 @@ class Seq2SeqAttInferModel(Seq2SeqAttModel):
return
rs
return
rs
class
WeightCrossEntropy
(
fluid
.
dygraph
.
Layer
):
class
WeightCrossEntropy
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
WeightCrossEntropy
,
self
).
__init__
()
super
(
WeightCrossEntropy
,
self
).
__init__
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录