提交 3ec9465a authored 作者: David Warde-Farley's avatar David Warde-Farley

Replace [i for i in xrange()] with range()

上级 b438341d
...@@ -5347,13 +5347,13 @@ class TensorDotGrad(Op): ...@@ -5347,13 +5347,13 @@ class TensorDotGrad(Op):
_gx = numpy.tensordot(gz, y, tdot_axes) _gx = numpy.tensordot(gz, y, tdot_axes)
idx = numpy.hstack((sum_over_x, self.axes[0])) idx = numpy.hstack((sum_over_x, self.axes[0]))
newshapex = numpy.zeros(x.ndim) newshapex = numpy.zeros(x.ndim)
newshapex[[newpos for newpos in idx]] = [i for i in xrange(x.ndim)] newshapex[[newpos for newpos in idx]] = range(x.ndim)
gx[0] = numpy.transpose(_gx, newshapex) gx[0] = numpy.transpose(_gx, newshapex)
tdot_axes = [sum_over_x, range(x.ndim - len(self.axes[0]))] tdot_axes = [sum_over_x, range(x.ndim - len(self.axes[0]))]
_gy = numpy.tensordot(x, gz, tdot_axes) _gy = numpy.tensordot(x, gz, tdot_axes)
idy = numpy.hstack((self.axes[1], sum_over_y)) idy = numpy.hstack((self.axes[1], sum_over_y))
newshapey = numpy.zeros(y.ndim) newshapey = numpy.zeros(y.ndim)
newshapey[[newpos for newpos in idy]] = [i for i in xrange(y.ndim)] newshapey[[newpos for newpos in idy]] = range(y.ndim)
gy[0] = numpy.transpose(_gy, newshapey) gy[0] = numpy.transpose(_gy, newshapey)
tensordot_grad = TensorDotGrad tensordot_grad = TensorDotGrad
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论