Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
61182725
提交
61182725
authored
1月 21, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added log1p Op
上级
072bbb0f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
31 行增加
和
3 行删除
+31
-3
basic.py
theano/scalar/basic.py
+12
-0
basic.py
theano/tensor/basic.py
+4
-0
inplace.py
theano/tensor/inplace.py
+4
-0
test_basic.py
theano/tensor/tests/test_basic.py
+11
-3
没有找到文件。
theano/scalar/basic.py
浏览文件 @
61182725
...
...
@@ -1178,6 +1178,18 @@ class Log10(UnaryScalarOp):
return
"
%(z)
s = log10(
%(x)
s);"
%
locals
()
log10
=
Log10
(
upgrade_to_float
,
name
=
'log10'
)
class
Log1p
(
UnaryScalarOp
):
""" log(1+x) """
def
impl
(
self
,
x
):
return
numpy
.
log1p
(
x
)
def
grad
(
self
,
(
x
,),
(
gz
,)):
return
[
gz
/
(
1
+
x
)]
def
c_code
(
self
,
node
,
name
,
(
x
,
),
(
z
,
),
sub
):
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
raise
NotImplementedError
(
'type not supported'
,
type
)
return
"
%(z)
s = log1p(
%(x)
s);"
%
locals
()
log1p
=
Log1p
(
upgrade_to_float
,
name
=
'log1p'
)
class
Exp
(
UnaryScalarOp
):
def
impl
(
self
,
x
):
return
numpy
.
exp
(
x
)
...
...
theano/tensor/basic.py
浏览文件 @
61182725
...
...
@@ -1437,6 +1437,10 @@ def log2(a):
def
log10
(
a
):
"""base 10 logarithm of a"""
@_scal_elemwise
def
log1p
(
a
):
"""log(1+a)"""
@_scal_elemwise
def
sgn
(
a
):
"""sign of a"""
...
...
theano/tensor/inplace.py
浏览文件 @
61182725
...
...
@@ -100,6 +100,10 @@ def inv_inplace(a):
def
log_inplace
(
a
):
"""base e logarithm of a (inplace on a)"""
@_scal_inplace
def
log1p_inplace
(
a
):
"""log(1+a)"""
@_scal_inplace
def
log2_inplace
(
a
):
"""base 2 logarithm of a (inplace on a)"""
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
61182725
...
...
@@ -444,6 +444,17 @@ Log10InplaceTester = makeBroadcastTester(op = inplace.log10_inplace,
grad
=
_grad_broadcast_unary_positive
,
inplace
=
True
)
Log1pTester
=
makeBroadcastTester
(
op
=
log1p
,
expected
=
numpy
.
log1p
,
good
=
_good_broadcast_unary_positive
,
grad
=
_grad_broadcast_unary_positive
)
Log1pInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
log1p_inplace
,
expected
=
numpy
.
log1p
,
good
=
_good_broadcast_unary_positive
,
grad
=
_grad_broadcast_unary_positive
,
inplace
=
True
)
SqrtTester
=
makeBroadcastTester
(
op
=
sqrt
,
expected
=
numpy
.
sqrt
,
good
=
_good_broadcast_unary_positive
,
...
...
@@ -1088,9 +1099,7 @@ class test_bitwise(unittest.TestCase):
self
.
failUnless
(
numpy
.
all
(
v
==
(
~
l
)),
(
l
,
r
,
v
))
class
T_add
(
unittest
.
TestCase
):
def
setUp
(
self
):
utt
.
seed_rng
()
...
...
@@ -1118,7 +1127,6 @@ class T_add(unittest.TestCase):
utt
.
verify_grad
(
add
,
[
numpy
.
random
.
rand
(
3
,
5
),
numpy
.
random
.
rand
(
3
,
1
)])
class
T_exp
(
unittest
.
TestCase
):
def
test_grad_0
(
self
):
utt
.
verify_grad
(
exp
,
[
numpy
.
asarray
([[
1.5089518
,
1.48439076
,
-
4.7820262
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论