Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a6348816
提交
a6348816
authored
7月 04, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change CPU CTC Op to use _cop_num_outputs
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
e2b07918
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
26 行删除
+11
-26
ctc.py
theano/tensor/nnet/ctc.py
+11
-11
ctc_wrapper.c
theano/tensor/nnet/ctc_wrapper.c
+0
-15
没有找到文件。
theano/tensor/nnet/ctc.py
浏览文件 @
a6348816
...
@@ -30,23 +30,27 @@ class ConnectionistTemporalClassification(gof.COp, gof.OpenMPOp):
...
@@ -30,23 +30,27 @@ class ConnectionistTemporalClassification(gof.COp, gof.OpenMPOp):
"""
"""
__props__
=
(
'compute_grad'
,)
__props__
=
(
'compute_grad'
,)
_cop_num_inputs
=
3
_cop_num_outputs
=
2
func_file
=
"./ctc_wrapper.c"
func_file
=
"./ctc_wrapper.c"
func_name
=
"APPLY_SPECIFIC(ctc_cost_cpu)"
func_name
=
"APPLY_SPECIFIC(ctc_cost_cpu)"
def
__init__
(
self
,
compute_grad
=
True
):
def
__init__
(
self
,
compute_grad
=
True
):
if
not
compute_grad
:
if
not
ctc_enabled
:
self
.
func_name
=
"APPLY_SPECIFIC(ctc_cost_cpu_no_grad)"
raise
RuntimeError
(
'Baidu CTC is not enabled and '
'ConnectionistTemporalClassification Op '
'can not be constructed.'
)
elif
config
.
ctc
.
root
==
""
:
raise
ValueError
(
'ctc.root variable is not set, please set it '
'to the root directory of the CTC library in '
'your system.'
)
gof
.
COp
.
__init__
(
self
,
self
.
func_file
,
self
.
func_name
)
gof
.
COp
.
__init__
(
self
,
self
.
func_file
,
self
.
func_name
)
gof
.
OpenMPOp
.
__init__
(
self
)
gof
.
OpenMPOp
.
__init__
(
self
)
self
.
compute_grad
=
compute_grad
self
.
compute_grad
=
compute_grad
if
config
.
ctc
.
root
==
""
:
raise
ValueError
(
'ctc.root variable is not set, please set it '
'to the root directory of the CTC library in '
'your system.'
)
def
c_lib_dirs
(
self
):
def
c_lib_dirs
(
self
):
dirs
=
[]
dirs
=
[]
if
ctc_enabled
:
if
ctc_enabled
:
...
@@ -83,10 +87,6 @@ class ConnectionistTemporalClassification(gof.COp, gof.OpenMPOp):
...
@@ -83,10 +87,6 @@ class ConnectionistTemporalClassification(gof.COp, gof.OpenMPOp):
return
[
"ctc.h"
]
+
gof
.
OpenMPOp
.
c_headers
(
self
)
return
[
"ctc.h"
]
+
gof
.
OpenMPOp
.
c_headers
(
self
)
def
make_node
(
self
,
activations
,
labels
,
input_lengths
):
def
make_node
(
self
,
activations
,
labels
,
input_lengths
):
if
not
ctc_enabled
:
raise
RuntimeError
(
'Baidu CTC is not enabled and '
'ConnectionistTemporalClassification Op '
'can not be constructed.'
)
t_activations
=
T
.
as_tensor_variable
(
activations
)
t_activations
=
T
.
as_tensor_variable
(
activations
)
# Ensure activations array is C-contiguous
# Ensure activations array is C-contiguous
t_activations
=
cpu_contiguous
(
t_activations
)
t_activations
=
cpu_contiguous
(
t_activations
)
...
...
theano/tensor/nnet/ctc_wrapper.c
浏览文件 @
a6348816
...
@@ -250,18 +250,3 @@ int APPLY_SPECIFIC(ctc_cost_cpu)(PyArrayObject * in_activations,
...
@@ -250,18 +250,3 @@ int APPLY_SPECIFIC(ctc_cost_cpu)(PyArrayObject * in_activations,
return
0
;
return
0
;
}
}
/**
* Wrapper version with gradient computation disabled.
*/
int
APPLY_SPECIFIC
(
ctc_cost_cpu_no_grad
)(
PyArrayObject
*
in_activations
,
PyArrayObject
*
in_labels
,
PyArrayObject
*
in_input_lengths
,
PyArrayObject
**
out_costs
)
{
return
APPLY_SPECIFIC
(
ctc_cost_cpu
)(
in_activations
,
in_labels
,
in_input_lengths
,
out_costs
,
NULL
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论