提交 27401cf5 authored 作者: David Warde-Farley's avatar David Warde-Farley

BUG: dimension mismatch StructuredDotCS{R,C}Grad

dot() called on sparse matrices obeys 2D dimension matching rules, even if they are single row/columns. dot() called on (1, N) and (1, N) arguments, as was being done here, will fail. This transposes the second argument to fix the problem.
上级 247618cc
......@@ -1700,7 +1700,7 @@ class StructuredDotGradCSC(gof.Op):
ind1 = a_indptr[j + 1]
for i_idx in xrange(ind0, ind1):
i = a_indices[i_idx]
g_a_data[i_idx] = numpy.dot(g_ab[i], b[j])
g_a_data[i_idx] = numpy.dot(g_ab[i], b[j].T)[0, 0]
out[0] = g_a_data
def c_code(self, node, name, (_indices, _indptr, _d, _g), (_zout, ), sub):
......@@ -1815,7 +1815,7 @@ class StructuredDotGradCSR(gof.Op):
for j_idx in xrange(ind0, ind1):
j = a_indices[j_idx]
# grad is dot product of i-th row of gradient with j-th row of b
g_a_data[j_idx] = numpy.dot(g_ab[i], b[j])
g_a_data[j_idx] = numpy.dot(g_ab[i], b[j].T)[0, 0]
out[0] = g_a_data
def c_code(self, node, name, (_indices, _indptr, _d, _g), (_zout, ), sub):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论