Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fc9052e3
提交
fc9052e3
authored
5月 07, 2021
作者:
Ricardo
提交者:
Thomas Wiecki
5月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move sigmoid tests to respective files
Add tests for inplace Sigmoid and Softplus
上级
ec51faa6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
83 行增加
和
1 行删除
+83
-1
test_sigm.py
tests/tensor/nnet/test_sigm.py
+0
-0
test_basic_scipy.py
tests/tensor/test_basic_scipy.py
+82
-0
test_math.py
tests/tensor/test_math.py
+1
-1
test_math_opt.py
tests/tensor/test_math_opt.py
+0
-0
没有找到文件。
tests/tensor/nnet/test_sigm.py
浏览文件 @
fc9052e3
差异被折叠。
点击展开。
tests/tensor/test_basic_scipy.py
浏览文件 @
fc9052e3
...
...
@@ -17,13 +17,17 @@ from tests.tensor.utils import (
_good_broadcast_unary_normal_float
,
_good_broadcast_unary_normal_float_no_complex
,
_good_broadcast_unary_normal_float_no_complex_small_neg_range
,
_good_broadcast_unary_normal_no_complex
,
_grad_broadcast_unary_0_2_no_complex
,
_grad_broadcast_unary_abs1_no_complex
,
_grad_broadcast_unary_normal
,
_grad_broadcast_unary_normal_small_neg_range
,
check_floatX
,
copymod
,
makeBroadcastTester
,
rand_ranged
,
randint_ranged
,
upcast_int8_nfunc
,
)
...
...
@@ -72,6 +76,7 @@ if imported_scipy_special:
expected_i1
=
scipy
.
special
.
i1
expected_iv
=
scipy
.
special
.
iv
expected_erfcx
=
scipy
.
special
.
erfcx
expected_sigmoid
=
scipy
.
special
.
expit
skip_scipy
=
False
else
:
expected_erf
=
[]
...
...
@@ -94,6 +99,11 @@ else:
expected_i0
=
[]
expected_i1
=
[]
expected_iv
=
[]
expected_sigmoid
=
(
upcast_int8_nfunc
(
lambda
inputs
:
check_floatX
(
inputs
,
np
.
log1p
(
np
.
exp
(
inputs
)))
),
)
skip_scipy
=
"scipy is not present"
TestErfBroadcast
=
makeBroadcastTester
(
...
...
@@ -563,3 +573,75 @@ def test_verify_iv_grad():
return
aet
.
iv
(
v_val
,
x
)
utt
.
verify_grad
(
fixed_first_input_iv
,
[
x_val
])
TestSigmoidBroadcast
=
makeBroadcastTester
(
op
=
aet
.
sigmoid
,
expected
=
expected_sigmoid
,
good
=
_good_broadcast_unary_normal_no_complex
,
eps
=
1e-8
,
)
TestSigmoidInplaceBroadcast
=
makeBroadcastTester
(
op
=
inplace
.
sigmoid_inplace
,
expected
=
expected_sigmoid
,
good
=
_good_broadcast_unary_normal_no_complex
,
grad
=
_grad_broadcast_unary_normal
,
eps
=
1e-8
,
inplace
=
True
,
)
class
TestSigmoid
:
def
setup_method
(
self
):
utt
.
seed_rng
()
def
test_elemwise
(
self
):
utt
.
verify_grad
(
aet
.
sigmoid
,
[
np
.
random
.
rand
(
3
,
4
)])
_good_broadcast_unary_softplus
=
dict
(
copymod
(
_good_broadcast_unary_normal_no_complex
,
without
=
[
"uint8"
,
"uint16"
,
"big_scalar"
],
),
# numpy function overflows with uint16.
uint8
=
[
np
.
arange
(
0
,
89
,
dtype
=
"uint8"
)
],
# the range is different in new added uint8.
int8
=
[
np
.
arange
(
-
127
,
89
,
dtype
=
"int8"
)],
)
expected_sofplus
=
upcast_int8_nfunc
(
lambda
inputs
:
check_floatX
(
inputs
,
np
.
log1p
(
np
.
exp
(
inputs
)))
)
TestSoftplusBroadcast
=
makeBroadcastTester
(
op
=
aet
.
softplus
,
expected
=
expected_sofplus
,
good
=
_good_broadcast_unary_softplus
,
eps
=
1e-8
,
)
TestSoftplusInplaceBroadcast
=
makeBroadcastTester
(
op
=
inplace
.
softplus_inplace
,
expected
=
expected_sofplus
,
good
=
_good_broadcast_unary_softplus
,
grad
=
_grad_broadcast_unary_normal
,
eps
=
1e-8
,
inplace
=
True
,
)
class
TestSoftplus
:
def
setup_method
(
self
):
utt
.
seed_rng
()
def
test_elemwise
(
self
):
utt
.
verify_grad
(
aet
.
softplus
,
[
np
.
random
.
rand
(
3
,
4
)])
def
test_accuracy
(
self
):
# Test all aproximations are working (cutoff points are -37, 18, 33.3)
x_test
=
np
.
array
([
-
40.0
,
-
17.5
,
17.5
,
18.5
,
40.0
])
y_th
=
aet
.
softplus
(
x_test
)
.
eval
()
y_np
=
np
.
log1p
(
np
.
exp
(
x_test
))
np
.
testing
.
assert_allclose
(
y_th
,
y_np
,
rtol
=
10e-10
)
tests/tensor/test_math.py
浏览文件 @
fc9052e3
...
...
@@ -93,6 +93,7 @@ from aesara.tensor.math import (
round_half_away_from_zero
,
round_half_to_even
,
sgn
,
sigmoid
,
sin
,
sinh
,
smallest
,
...
...
@@ -102,7 +103,6 @@ from aesara.tensor.math import (
)
from
aesara.tensor.math
import
sum
as
aet_sum
from
aesara.tensor.math
import
tan
,
tanh
,
tensordot
,
true_div
,
trunc
,
var
from
aesara.tensor.nnet
import
sigmoid
from
aesara.tensor.type
import
(
TensorType
,
complex_dtypes
,
...
...
tests/tensor/test_math_opt.py
浏览文件 @
fc9052e3
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论