提交 2866d21b authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Explicitly give the shape, since -1 does not work when there were zeros

上级 5da5805d
...@@ -1421,8 +1421,10 @@ class MaxAndArgmax(Op): ...@@ -1421,8 +1421,10 @@ class MaxAndArgmax(Op):
dtype='int64') dtype='int64')
# Not-reduced axes in front # Not-reduced axes in front
transposed_x = numpy.transpose(x, numpy.concatenate((keep_axes, axes))) transposed_x = numpy.transpose(x, numpy.concatenate((keep_axes, axes)))
reshaped_x = transposed_x.reshape(transposed_x.shape[:len(keep_axes)] + kept_shape = transposed_x.shape[:len(keep_axes)]
(-1,)) reduced_shape = transposed_x.shape[len(keep_axes):]
new_shape = kept_shape + (numpy.prod(reduced_shape),)
reshaped_x = transposed_x.reshape(new_shape)
max_idx[0] = theano._asarray(numpy.argmax(reshaped_x, axis=-1), max_idx[0] = theano._asarray(numpy.argmax(reshaped_x, axis=-1),
dtype='int64') dtype='int64')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论