Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3912f005
提交
3912f005
authored
3月 25, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow bit-wise op to be of type int16 and add test for all allowed type.
上级
163a00fd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
31 行删除
+40
-31
basic.py
theano/scalar/basic.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+39
-30
没有找到文件。
theano/scalar/basic.py
浏览文件 @
3912f005
...
@@ -778,7 +778,7 @@ switch = Switch()
...
@@ -778,7 +778,7 @@ switch = Switch()
class
UnaryBitOp
(
UnaryScalarOp
):
class
UnaryBitOp
(
UnaryScalarOp
):
def
output_types
(
self
,
*
input_types
):
def
output_types
(
self
,
*
input_types
):
for
i
in
input_types
[
0
]:
for
i
in
input_types
[
0
]:
if
i
not
in
(
int8
,
int32
,
int64
):
if
i
not
in
(
int8
,
int
16
,
int
32
,
int64
):
raise
TypeError
(
'input to a BitOp must have type int8, int32 or int64... not
%
s'
%
i
)
raise
TypeError
(
'input to a BitOp must have type int8, int32 or int64... not
%
s'
%
i
)
return
upcast_out
(
*
input_types
[
0
])
return
upcast_out
(
*
input_types
[
0
])
def
grad
(
self
,
inputs
,
output_gradients
):
def
grad
(
self
,
inputs
,
output_gradients
):
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
3912f005
...
@@ -2458,43 +2458,52 @@ class test_comparison(unittest.TestCase):
...
@@ -2458,43 +2458,52 @@ class test_comparison(unittest.TestCase):
self
.
failUnless
(
numpy
.
all
(
v
==
(
l
!=
r
)),
(
v
,
(
l
!=
r
)))
self
.
failUnless
(
numpy
.
all
(
v
==
(
l
!=
r
)),
(
v
,
(
l
!=
r
)))
class
test_bitwise
(
unittest
.
TestCase
):
class
test_bitwise
(
unittest
.
TestCase
):
dtype
=
[
'int8'
,
'int16'
,
'int32'
,
'int64'
,]
def
test_or
(
self
):
def
test_or
(
self
):
x
,
y
=
bvector
(),
bvector
()
for
dtype
in
self
.
dtype
:
fn
=
inplace_func
([
x
,
y
],
x
|
y
)
x
,
y
=
vector
(
dtype
=
dtype
),
vector
(
dtype
=
dtype
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
'int8'
)
fn
=
inplace_func
([
x
,
y
],
x
|
y
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
'int8'
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
dtype
)
v
=
fn
(
l
,
r
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
dtype
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
or_
(
l
,
r
))),
(
l
,
r
,
v
))
v
=
fn
(
l
,
r
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
or_
(
l
,
r
))),
(
l
,
r
,
v
))
def
test_xor
(
self
):
def
test_xor
(
self
):
x
,
y
=
bvector
(),
bvector
()
for
dtype
in
self
.
dtype
:
fn
=
inplace_func
([
x
,
y
],
x
^
y
)
x
,
y
=
vector
(
dtype
=
dtype
),
vector
(
dtype
=
dtype
)
ix
=
x
fn
=
inplace_func
([
x
,
y
],
x
^
y
)
ix
=
inplace
.
xor_inplace
(
ix
,
y
)
ix
=
x
gn
=
inplace_func
([
x
,
y
],
ix
)
ix
=
inplace
.
xor_inplace
(
ix
,
y
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
'int8'
)
gn
=
inplace_func
([
x
,
y
],
ix
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
'int8'
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
dtype
)
v
=
fn
(
l
,
r
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
dtype
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
xor
(
l
,
r
))),
(
l
,
r
,
v
))
v
=
fn
(
l
,
r
)
v
=
gn
(
l
,
r
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
xor
(
l
,
r
))),
(
l
,
r
,
v
))
#test the in-place stuff
v
=
gn
(
l
,
r
)
self
.
failUnless
(
numpy
.
all
(
l
==
numpy
.
asarray
([
0
,
1
,
1
,
0
])),
l
)
#test the in-place stuff
self
.
failUnless
(
numpy
.
all
(
l
==
numpy
.
asarray
([
0
,
1
,
1
,
0
])),
l
)
def
test_and
(
self
):
def
test_and
(
self
):
x
,
y
=
bvector
(),
bvector
()
for
dtype
in
self
.
dtype
:
fn
=
inplace_func
([
x
,
y
],
x
&
y
)
x
,
y
=
vector
(
dtype
=
dtype
),
vector
(
dtype
=
dtype
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
'int8'
)
fn
=
inplace_func
([
x
,
y
],
x
&
y
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
'int8'
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
dtype
)
v
=
fn
(
l
,
r
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
dtype
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
and_
(
l
,
r
))),
(
l
,
r
,
v
))
v
=
fn
(
l
,
r
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
and_
(
l
,
r
))),
(
l
,
r
,
v
))
def
test_inv
(
self
):
def
test_inv
(
self
):
x
,
y
=
bvector
(),
bvector
()
for
dtype
in
self
.
dtype
:
fn
=
inplace_func
([
x
,
y
],
~
x
)
x
=
vector
(
dtype
=
dtype
)
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
'int8'
)
fn
=
inplace_func
([
x
],
~
x
)
r
=
theano
.
_asarray
([
0
,
1
,
0
,
1
],
dtype
=
'int8'
)
for
l
in
[[
0
,
0
,
1
,
1
],[
0
,
1
,
0
,
1
],
v
=
fn
(
l
,
r
)
[
0
,
0
,
1
,
1
],[
0
,
1
,
0
,
1
],
self
.
failUnless
(
numpy
.
all
(
v
==
(
~
l
)),
(
l
,
r
,
v
))
[
-
1
,
2
**
16
,
2
**
16
-
1
]
]:
l
=
theano
.
_asarray
([
0
,
0
,
1
,
1
],
dtype
=
dtype
)
v
=
fn
(
l
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
~
l
)),
(
l
,
v
))
def
test_eye
(
self
):
def
test_eye
(
self
):
n
=
iscalar
()
n
=
iscalar
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论