Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2d720dcc
提交
2d720dcc
authored
6月 13, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix setup of symbolic gradients in CTC test
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
5213ba52
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
7 行增加
和
7 行删除
+7
-7
test_ctc.py
theano/gpuarray/tests/test_ctc.py
+7
-7
没有找到文件。
theano/gpuarray/tests/test_ctc.py
浏览文件 @
2d720dcc
...
...
@@ -26,7 +26,7 @@ class TestCTC(unittest.TestCase):
# Compute CTC costs and gradients on the CPU to compare with GPU
cpu_ctc_cost
=
ctc
(
t_activations
,
t_labels
,
t_activation_times
)
# Symbolic gradient of CTC cost
cpu_ctc_grad
=
T
.
grad
(
T
.
mean
(
t
_cost
),
t_activations
)
cpu_ctc_grad
=
T
.
grad
(
T
.
mean
(
cpu_ctc
_cost
),
t_activations
)
# Compile CPU function without optimization
cpu_train
=
theano
.
function
([],
[
cpu_ctc_cost
,
cpu_ctc_grad
],
mode
=
mode_without_gpu
)
...
...
@@ -34,7 +34,7 @@ class TestCTC(unittest.TestCase):
gpu_ctc_cost
=
gpu_ctc
(
t_activations
,
t_labels
,
t_activation_times
)
# Symbolic gradient of CTC cost
gpu_ctc_grad
=
T
.
grad
(
T
.
mean
(
t
_cost
),
t_activations
)
gpu_ctc_grad
=
T
.
grad
(
T
.
mean
(
gpu_ctc
_cost
),
t_activations
)
# Compile symbolic functions
gpu_train
=
theano
.
function
([],
[
gpu_ctc_cost
,
gpu_ctc_grad
])
...
...
@@ -46,7 +46,7 @@ class TestCTC(unittest.TestCase):
grad_from_gpu
=
np
.
asarray
(
gpu_grad
)
# Check that results are in conformance with expected values
utt
.
assert_allclose
(
expected_grads
/
gpu_ctc_cost
.
shape
[
0
],
grad_from_gpu
)
utt
.
assert_allclose
(
expected_grads
/
cost_from_gpu
.
shape
[
0
],
grad_from_gpu
)
utt
.
assert_allclose
(
expected_costs
,
cost_from_gpu
)
# Compare values obtained from CPU and GPU implementations
...
...
@@ -87,13 +87,13 @@ class TestCTC(unittest.TestCase):
def
test_ctc
(
self
):
activations
=
np
.
asarray
([[[
0.1
,
0.6
,
0.1
,
0.1
,
0.1
],
[
0.1
,
0.1
,
0.6
,
0.1
,
0.1
]],
[[
0.6
,
0.1
,
0.1
,
0.1
,
0.1
],
[
0.1
,
0.1
,
0.5
,
0.2
,
0.1
]]],
dtype
=
'float32'
)
dtype
=
np
.
float32
)
activation_times
=
np
.
asarray
([
2
,
2
],
dtype
=
'int32'
)
activation_times
=
np
.
asarray
([
2
,
2
],
dtype
=
np
.
int32
)
labels
=
np
.
asarray
([[
1
,
2
],
[
1
,
2
]],
dtype
=
'int32'
)
labels
=
np
.
asarray
([[
1
,
2
],
[
1
,
2
]],
dtype
=
np
.
int32
)
expected_costs
=
np
.
asarray
([
2.962858438
,
3.053659201
],
dtype
=
'float32'
)
expected_costs
=
np
.
asarray
([
2.962858438
,
3.053659201
],
dtype
=
np
.
float32
)
grads
=
[[[
0.177031219
,
-
0.7081246376
,
0.177031219
,
0.177031219
,
0.177031219
],
[
0.177031219
,
-
0.8229685426
,
0.291875124
,
0.177031219
,
0.177031219
]],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论