提交 4346b4c5 authored 作者: lamblin's avatar lamblin

Merge pull request #960 from nouiz/np1.5

Np1.5
...@@ -854,7 +854,7 @@ class CSMGrad(gof.op.Op): ...@@ -854,7 +854,7 @@ class CSMGrad(gof.op.Op):
sp_dim = x_shape[0] sp_dim = x_shape[0]
g_row = numpy.zeros(sp_dim, dtype=g_data.dtype) g_row = numpy.zeros(sp_dim, dtype=g_data.dtype)
gout_data = numpy.zeros_like(x_data, dtype=node.outputs[0].dtype) gout_data = numpy.zeros(x_data.shape, dtype=node.outputs[0].dtype)
for i in range(len(x_indptr) - 1): for i in range(len(x_indptr) - 1):
for j_ptr in range(g_indptr[i], g_indptr[i + 1]): for j_ptr in range(g_indptr[i], g_indptr[i + 1]):
......
...@@ -127,14 +127,19 @@ def sparse_random_inputs(format, shape, n=1, out_dtype=None, p=0.5, gap=None): ...@@ -127,14 +127,19 @@ def sparse_random_inputs(format, shape, n=1, out_dtype=None, p=0.5, gap=None):
value = a + numpy.random.random(shape) * (b - a) value = a + numpy.random.random(shape) * (b - a)
else: else:
value = numpy.random.random(shape) * gap[0] value = numpy.random.random(shape) * gap[0]
return (where * value).astype(out_dtype)
value.astype(out_dtype)
return where * value
variable = [getattr(theano.sparse, format + '_matrix')(dtype=out_dtype) variable = [getattr(theano.sparse, format + '_matrix')(dtype=out_dtype)
for k in range(n)] for k in range(n)]
data = [getattr(scipy.sparse, format + '_matrix')(_rand(), dtype=out_dtype) data = [getattr(scipy.sparse, format + '_matrix')(_rand(), dtype=out_dtype)
for k in range(n)] for k in range(n)]
#numpy 1.5.0 with scipy 0.9.0 have scipy.sparse.XXX_matrix return
#typenum 10(ulonglong) instead of 8(uint64) event if they are the same!
#Theano don't like ulonglong type_num
dtype = numpy.dtype(out_dtype) # Convert into dtype object.
if data[0].dtype.num != dtype.num and dtype.str == data[0].dtype.str:
data[0].data = theano._asarray(data[0].data, out_dtype)
assert data[0].dtype.num == dtype.num
return (variable, data) return (variable, data)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论