提交 4631b6ef authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use int64 in reduction instead of casting to int

casting to int could lead to issues in the following case: - 64-bit Windows - python 2 - shape bigger than 2**31 In that case, int would be 32-bit, but shapes could be bigger and stored in long.
上级 83d3c3fb
......@@ -1233,9 +1233,9 @@ class MaxAndArgmax(Op):
kept_shape = transposed_x.shape[:len(keep_axes)]
reduced_shape = transposed_x.shape[len(keep_axes):]
# Numpy.prod returns 1.0 when arg is empty, so we cast it to int
# Otherwise reshape would complain citiing float arg
new_shape = kept_shape + (int(numpy.prod(reduced_shape)),)
# Numpy.prod returns 1.0 when arg is empty, so we cast it to int64
# Otherwise reshape would complain citing float arg
new_shape = kept_shape + (numpy.prod(reduced_shape, dtype='int64'),)
reshaped_x = transposed_x.reshape(new_shape)
max_idx[0] = theano._asarray(numpy.argmax(reshaped_x, axis=-1),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论