提交 fc7709fa authored 作者: Tanjay94's avatar Tanjay94

Fixed norm function and added it to var.py.

上级 d5e160a6
...@@ -1278,7 +1278,7 @@ def norm(x,ord,axis): ...@@ -1278,7 +1278,7 @@ def norm(x,ord,axis):
z = tensor.min(abs(x),axis) z = tensor.min(abs(x),axis)
return z return z
elif ord == 0: elif ord == 0:
z = tensor.sum(tensor.neq(x,0),1) z = tensor.sum(tensor.neq(x,0),axis)
return z return z
else: else:
try: try:
......
...@@ -650,3 +650,7 @@ class T_NormTests(unittest.TestCase): ...@@ -650,3 +650,7 @@ class T_NormTests(unittest.TestCase):
self.assertRaises(TypeError, norm, 3, None, None) self.assertRaises(TypeError, norm, 3, None, None)
def test_no_enough_dimensions(self): def test_no_enough_dimensions(self):
self.assertRaises(ValueError, norm, [[2,1],[3,4]], None, 3) self.assertRaises(ValueError, norm, [[2,1],[3,4]], None, 3)
def test(self):
x = theano.tensor.matrix()
x.swapaxes()
...@@ -699,7 +699,7 @@ class TensorConstant(_tensor_py_operators, Constant): ...@@ -699,7 +699,7 @@ class TensorConstant(_tensor_py_operators, Constant):
copy.deepcopy(self.data, memo), copy.deepcopy(self.data, memo),
copy.deepcopy(self.name, memo)) copy.deepcopy(self.name, memo))
def swapaxes(self, axis1, axis2) def swapaxes(self, axis1, axis2)
"""Return 'tensor.swapaxes(self, axis1, axis2) """Return 'tensor.swapaxes(self, axis1, axis2)
If a matrix is provided with the right axes, its transpose will be returned. If a matrix is provided with the right axes, its transpose will be returned.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论