提交 7e675cad authored 作者: fsavard's avatar fsavard

merge

...@@ -1173,22 +1173,10 @@ class Prod(CAReduce): ...@@ -1173,22 +1173,10 @@ class Prod(CAReduce):
new_dims.append(i) new_dims.append(i)
i += 1 i += 1
# fill a matrix with the same shape as x by broadcasting p_gz = theano.tensor.mul(prod_out, gz)
# values taken from gz, which has the same shape as the output p_gz = DimShuffle(p_gz.type.broadcastable, new_dims)(p_gz)
# of prod().
gz_filled_x = Elemwise(scalar.second)(x, return [Elemwise(scalar.true_div)(p_gz, x)]
DimShuffle(gz.type.broadcastable, new_dims)(gz))
# do the same with the output of prod, by broadcasting along
# axises where the product was taken
prod_out_filled_x = Elemwise(scalar.second)(x,
DimShuffle(prod_out.type.broadcastable,
new_dims)(prod_out))
return [theano.tensor.mul(gz_filled_x,
theano.tensor.true_div(prod_out_filled_x, x))]
#else:
# raise NotImplementedError('Will be implemented shortly')
def __str__(self): def __str__(self):
if self.axis is None: if self.axis is None:
......
...@@ -301,5 +301,6 @@ class test_Prod(unittest.TestCase): ...@@ -301,5 +301,6 @@ class test_Prod(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
#suite = unittest.TestSuite([test_Prod('test_prod_grad')]) #suite = unittest.TestSuite([test_Prod('test_prod_grad')])
#suite.addTest(test_Prod('test_verify_grad'))
#unittest.TextTestRunner().run(suite) #unittest.TextTestRunner().run(suite)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论