Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
08d9e9b1
提交
08d9e9b1
authored
4月 30, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added tensor.round and tensor.iround and their doc.
上级
5f4093e7
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
20 行增加
和
24 行删除
+20
-24
basic.txt
doc/library/tensor/basic.txt
+6
-2
basic.py
theano/scalar/basic.py
+0
-7
basic.py
theano/tensor/basic.py
+14
-3
inplace.py
theano/tensor/inplace.py
+0
-4
test_basic.py
theano/tensor/tests/test_basic.py
+0
-8
没有找到文件。
doc/library/tensor/basic.txt
浏览文件 @
08d9e9b1
...
...
@@ -954,9 +954,13 @@ Mathematical
Returns a variable representing the floor of a (for example floor(2.9) is 2).
.. function::
iround(a
)
.. function::
round(a, mode="half_away_from_zero"
)
Returns a variable representing the of rounding of a, ie int(a).
Returns a variable representing the rounding of a in the same dtype as a. Implemented rounding mode are half_away_from_zero and half_to_even.
.. function:: iround(a, mode="half_away_from_zero")
Short hand for cast(round(a, mode),'int64').
.. function:: sqr(a)
...
...
theano/scalar/basic.py
浏览文件 @
08d9e9b1
...
...
@@ -1145,13 +1145,6 @@ class Floor(UnaryScalarOp):
return
"
%(z)
s = floor(
%(x)
s);"
%
locals
()
floor
=
Floor
(
same_out_nocomplex
,
name
=
'floor'
)
class
IRound
(
UnaryScalarOp
):
def
impl
(
self
,
x
):
return
theano
.
_asarray
(
numpy
.
round
(
x
),
dtype
=
'int64'
)
def
c_code
(
self
,
node
,
name
,
(
x
,
),
(
z
,
),
sub
):
return
"
%(z)
s = round(
%(x)
s);"
%
locals
()
iround
=
IRound
(
int_out_nocomplex
)
class
RoundHalfToEven
(
UnaryScalarOp
):
"""
This function implement the same rounding than numpy: Round half to even
...
...
theano/tensor/basic.py
浏览文件 @
08d9e9b1
...
...
@@ -1574,9 +1574,20 @@ def ceil(a):
def
floor
(
a
):
"""floor of a"""
@_scal_elemwise
def
iround
(
a
):
"""int(round(a))"""
@constructor
def
iround
(
a
,
mode
=
"half_away_from_zero"
):
"""cast(round(a,mode),'int64')"""
return
cast
(
round
(
a
,
mode
),
'int64'
)
@constructor
def
round
(
a
,
mode
=
"half_away_from_zero"
):
"""round_mode(a) with mode in [half_away_from_zero, half_to_even]"""
if
mode
==
"half_away_from_zero"
:
return
round_half_away_from_zero
(
a
)
elif
mode
==
"half_to_even"
:
return
round_half_to_even
(
a
)
else
:
raise
Exception
(
"round mode
%
s is not implemented."
%
mode
)
@_scal_elemwise
def
round_half_to_even
(
a
):
...
...
theano/tensor/inplace.py
浏览文件 @
08d9e9b1
...
...
@@ -124,10 +124,6 @@ def ceil_inplace(a):
def
floor_inplace
(
a
):
"""floor of `a` (inplace on `a`)"""
@_scal_inplace
def
iround_inplace
(
a
):
"""int(round(a)) (inplace on `a`)"""
@_scal_inplace
def
round_half_to_even_inplace
(
a
):
"""round_half_to_even_inplace(a) (inplace on `a`)"""
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
08d9e9b1
...
...
@@ -445,14 +445,6 @@ FloorInplaceTester = makeBroadcastTester(op = inplace.floor_inplace,
grad
=
_grad_broadcast_unary_normal
,
inplace
=
True
)
IRoundTester
=
makeBroadcastTester
(
op
=
iround
,
expected
=
lambda
a
:
numpy
.
asarray
(
numpy
.
round
(
a
),
dtype
=
'int64'
),
good
=
_good_broadcast_unary_normal
)
IRoundInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
iround_inplace
,
expected
=
lambda
a
:
numpy
.
asarray
(
numpy
.
round
(
a
),
dtype
=
'int64'
),
good
=
_good_broadcast_unary_normal
,
inplace
=
True
)
RoundHalfToEvenTester
=
makeBroadcastTester
(
op
=
round_half_to_even
,
expected
=
numpy
.
round
,
good
=
_good_broadcast_unary_normal_float
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论