提交 5d8526de authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #3942 from shabanian/tensor_signal_pep8

change shape dimensions int32 to int64
...@@ -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('int32') shape = shape_.astype('int64')
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='int32') v_shape = tensor.constant([], dtype='int64')
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, 'int32'), tuple(bcast) return ndim, tensor.cast(v_shape, 'int64'), tuple(bcast)
def _generate_broadcasting_indices(out_shape, *shapes): def _generate_broadcasting_indices(out_shape, *shapes):
...@@ -521,11 +521,10 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None, ...@@ -521,11 +521,10 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None,
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':
try:
numpy.random.binomial(n=numpy.asarray([2, 3, 4], dtype='int64'), p=numpy.asarray([.1, .2, .3], dtype='float64'))
except TypeError:
# 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:
# numpy.random.binomial(
# n=numpy.asarray([2,3,4], dtype='int64'),
# p=numpy.asarray([.1, .2, .3], dtype='float64'))
n = tensor.cast(n, 'int32') n = tensor.cast(n, 'int32')
op = RandomFunction('binomial', op = RandomFunction('binomial',
tensor.TensorType(dtype=dtype, tensor.TensorType(dtype=dtype,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论