Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2d750998
提交
2d750998
authored
1月 28, 2016
作者:
Samira Shabanian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change shape dimensions int32 to int64
上级
91fe71d9
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
5 行增加
和
5 行删除
+5
-5
raw_random.py
theano/tensor/raw_random.py
+5
-5
没有找到文件。
theano/tensor/raw_random.py
浏览文件 @
2d750998
...
@@ -184,7 +184,7 @@ class RandomFunction(gof.Op):
...
@@ -184,7 +184,7 @@ class RandomFunction(gof.Op):
"""
"""
shape_
=
tensor
.
as_tensor_variable
(
shape
,
ndim
=
1
)
shape_
=
tensor
.
as_tensor_variable
(
shape
,
ndim
=
1
)
if
shape
==
():
if
shape
==
():
shape
=
shape_
.
astype
(
'int
32
'
)
shape
=
shape_
.
astype
(
'int
64
'
)
else
:
else
:
shape
=
shape_
shape
=
shape_
assert
shape
.
type
.
ndim
==
1
assert
shape
.
type
.
ndim
==
1
...
@@ -363,7 +363,7 @@ def _infer_ndim_bcast(ndim, shape, *args):
...
@@ -363,7 +363,7 @@ def _infer_ndim_bcast(ndim, shape, *args):
# post-condition: shape may still contain both symbolic and
# post-condition: shape may still contain both symbolic and
# non-symbolic things
# non-symbolic things
if
len
(
pre_v_shape
)
==
0
:
if
len
(
pre_v_shape
)
==
0
:
v_shape
=
tensor
.
constant
([],
dtype
=
'int
32
'
)
v_shape
=
tensor
.
constant
([],
dtype
=
'int
64
'
)
else
:
else
:
v_shape
=
tensor
.
stack
(
pre_v_shape
)
v_shape
=
tensor
.
stack
(
pre_v_shape
)
...
@@ -402,7 +402,7 @@ def _infer_ndim_bcast(ndim, shape, *args):
...
@@ -402,7 +402,7 @@ def _infer_ndim_bcast(ndim, shape, *args):
(
ndim
,
args_ndim
),
args
)
(
ndim
,
args_ndim
),
args
)
assert
ndim
==
len
(
bcast
)
assert
ndim
==
len
(
bcast
)
return
ndim
,
tensor
.
cast
(
v_shape
,
'int
32
'
),
tuple
(
bcast
)
return
ndim
,
tensor
.
cast
(
v_shape
,
'int
64
'
),
tuple
(
bcast
)
def
_generate_broadcasting_indices
(
out_shape
,
*
shapes
):
def
_generate_broadcasting_indices
(
out_shape
,
*
shapes
):
...
@@ -520,13 +520,13 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None,
...
@@ -520,13 +520,13 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None,
n
=
tensor
.
as_tensor_variable
(
n
)
n
=
tensor
.
as_tensor_variable
(
n
)
p
=
tensor
.
as_tensor_variable
(
p
)
p
=
tensor
.
as_tensor_variable
(
p
)
ndim
,
size
,
bcast
=
_infer_ndim_bcast
(
ndim
,
size
,
n
,
p
)
ndim
,
size
,
bcast
=
_infer_ndim_bcast
(
ndim
,
size
,
n
,
p
)
if
n
.
dtype
==
'int64'
:
#
if n.dtype == 'int64':
# THIS WORKS AROUND A NUMPY BUG on 32bit machine
# THIS WORKS AROUND A NUMPY BUG on 32bit machine
# Erase when the following works on a 32bit machine:
# Erase when the following works on a 32bit machine:
# numpy.random.binomial(
# numpy.random.binomial(
# n=numpy.asarray([2,3,4], dtype='int64'),
# n=numpy.asarray([2,3,4], dtype='int64'),
# p=numpy.asarray([.1, .2, .3], dtype='float64'))
# p=numpy.asarray([.1, .2, .3], dtype='float64'))
n
=
tensor
.
cast
(
n
,
'int32
'
)
n
=
tensor
.
cast
(
n
,
'int64
'
)
op
=
RandomFunction
(
'binomial'
,
op
=
RandomFunction
(
'binomial'
,
tensor
.
TensorType
(
dtype
=
dtype
,
tensor
.
TensorType
(
dtype
=
dtype
,
broadcastable
=
(
False
,)
*
ndim
))
broadcastable
=
(
False
,)
*
ndim
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论