Added test for Concatenate Op (gradient test not enable yet since the gradient…

Added test for Concatenate Op (gradient test not enable yet since the gradient implementation is currently buggy)
上级 8da18085
...@@ -956,6 +956,25 @@ class T_Stack(unittest.TestCase): ...@@ -956,6 +956,25 @@ class T_Stack(unittest.TestCase):
self.failUnless(numpy.all(gval[0] == 1.0)) self.failUnless(numpy.all(gval[0] == 1.0))
self.failUnless(numpy.all(gval[1] == 1.0)) self.failUnless(numpy.all(gval[1] == 1.0))
class T_Concatenate(unittest.TestCase):
def test_concatenate(self):
a_n = numpy.array([[1, 2, 3], [4, 5, 6]])
b_n = numpy.array([[7], [8]])
s = concatenate((as_tensor(a_n), as_tensor(b_n)), axis = 1)
c = numpy.concatenate((a_n, b_n), axis = 1)
self.failUnless((eval_outputs([s]) == c).all())
def test_concatenate_grad(self):
return # Not working yet
a_n = numpy.array([[1, 2, 3], [4, 5, 6]])
b_n = numpy.array([[7], [8]])
a = as_tensor(a_n)
b = as_tensor(b_n)
s = concatenate((a, b), axis = 1)
ga, gb = grad(sum(s), [a, b])
gval = eval_outputs([ga, gb])
self.failUnless(numpy.all(gval[0] == 1.0))
self.failUnless(numpy.all(gval[1] == 1.0))
class _test_comparison(unittest.TestCase): class _test_comparison(unittest.TestCase):
def test_gt(self): def test_gt(self):
...@@ -1751,7 +1770,7 @@ if __name__ == '__main__': ...@@ -1751,7 +1770,7 @@ if __name__ == '__main__':
if 1: if 1:
unittest.main() unittest.main()
else: else:
testcase = t_dot testcase = T_Concatenate
suite = unittest.TestLoader() suite = unittest.TestLoader()
suite = suite.loadTestsFromTestCase(testcase) suite = suite.loadTestsFromTestCase(testcase)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论