Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0def13ef
提交
0def13ef
authored
6月 09, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed a bug in the setting of output array flags in DimShuffle.c_code
上级
2a55ea5f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
5 行删除
+15
-5
elemwise.py
theano/tensor/elemwise.py
+6
-2
test_misc.py
theano/tensor/tests/test_misc.py
+9
-3
没有找到文件。
theano/tensor/elemwise.py
浏览文件 @
0def13ef
...
@@ -224,15 +224,19 @@ class DimShuffle(Op):
...
@@ -224,15 +224,19 @@ class DimShuffle(Op):
for
i
in
xrange
(
nd_out
-
2
,
-
1
,
-
1
):
for
i
in
xrange
(
nd_out
-
2
,
-
1
,
-
1
):
strides_statements
.
append
(
"if (strides[
%(i)
s] == 0) strides[
%(i)
s] = strides[
%(i)
s+1] * dimensions[
%(i)
s+1]"
%
dict
(
i
=
str
(
i
)))
strides_statements
.
append
(
"if (strides[
%(i)
s] == 0) strides[
%(i)
s] = strides[
%(i)
s+1] * dimensions[
%(i)
s+1]"
%
dict
(
i
=
str
(
i
)))
#
# PyObject* PyArray_New(PyTypeObject* subtype, int nd, npy_intp* dims, int type_num,
# npy_intp* strides, void* data, int itemsize, int flags, PyObject* obj)
#
close_bracket
=
[
close_bracket
=
[
#create a new array,
#create a new array,
(
'
%(res)
s = (PyArrayObject*)PyArray_New(&PyArray_Type, '
(
'
%(res)
s = (PyArrayObject*)PyArray_New(&PyArray_Type, '
''
+
str
(
nd_out
)
+
', dimensions, '
''
+
str
(
nd_out
)
+
', dimensions, '
'PyArray_TYPE(
%(basename)
s), strides, '
'PyArray_TYPE(
%(basename)
s), strides, '
'
%(basename)
s->data,
%(basename)
s->descr->elsize
, '
'
%(basename)
s->data,
PyArray_ITEMSIZE(
%(basename)
s)
, '
#borrow only the writable flag from the base
#borrow only the writable flag from the base
# the NPY_OWNDATA flag will default to 0.
# the NPY_OWNDATA flag will default to 0.
'
PyArray_ISWRITEABLE(
%(basename)
s
), NULL)'
),
'
(NPY_WRITEABLE*PyArray_ISWRITEABLE(
%(basename)
s)
), NULL)'
),
#recalculate flags: CONTIGUOUS, FORTRAN, ALIGNED
#recalculate flags: CONTIGUOUS, FORTRAN, ALIGNED
'PyArray_UpdateFlags(
%(res)
s, NPY_UPDATE_ALL)'
,
'PyArray_UpdateFlags(
%(res)
s, NPY_UPDATE_ALL)'
,
#we are making a view in both inplace and non-inplace cases
#we are making a view in both inplace and non-inplace cases
...
...
theano/tensor/tests/test_misc.py
浏览文件 @
0def13ef
import
sys
import
numpy
,
theano
import
numpy
,
theano
from
theano
import
tensor
from
theano
import
tensor
def
test_bug_2009_06_02
():
def
test_bug_2009_06_02
():
y
=
tensor
.
lvector
()
y
=
tensor
.
lvector
(
'y'
)
f
=
theano
.
function
([
y
],
tensor
.
stack
(
y
[
0
]
/
2
))
#f = theano.function([y], tensor.stack(y[0] / 2))
#f = theano.function([y], tensor.join(0,tensor.shape_padleft(y[0] / 2,1)))
f
=
theano
.
function
([
y
],
tensor
.
int_div
(
tensor
.
DimShuffle
(
y
[
0
]
.
broadcastable
,
[
'x'
])(
y
[
0
]),
2
))
sys
.
stdout
.
flush
()
print
f
(
numpy
.
ones
(
1
)
*
3
)
#z = tensor.lscalar('z')
#f = theano.function([z], tensor.DimShuffle([], ['x'])(z) / 2)
print
f
(
numpy
.
ones
(
1
)
*
2
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论