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

Fixed small mistake in norm and swapaxes function.

上级 43cfa11a
...@@ -1226,10 +1226,10 @@ def norm(x,ord): ...@@ -1226,10 +1226,10 @@ def norm(x,ord):
x = as_tensor_variable(x) x = as_tensor_variable(x)
ndim = x.ndim ndim = x.ndim
if ndim == 0: if ndim == 0:
raise TypeError raise ValueError("'axis' entry is out of bounds.")
elif ndim == 1: elif ndim == 1:
if ord == None: if ord == None:
z = (tensor.sum(x**2))**(0.5) z = tensor.sum(x**2)**0.5
return z return z
elif ord == 'inf': elif ord == 'inf':
z = tensor.max(abs(x)) z = tensor.max(abs(x))
...@@ -1238,13 +1238,13 @@ def norm(x,ord): ...@@ -1238,13 +1238,13 @@ def norm(x,ord):
z = tensor.min(abs(x)) z = tensor.min(abs(x))
return z return z
elif ord == 0: elif ord == 0:
z = (x[x.nonzero()]).shape[0] z = x[x.nonzero()].shape[0]
return z return z
else: else:
try: try:
z = (tensor.sum(abs(x**ord)))**(1./ord) z = tensor.sum(abs(x**ord))**(1./ord)
except TypeError: except TypeError:
raise ValueError raise ValueError("Invalid norm order for vectors.")
return z return z
elif ndim == 2: elif ndim == 2:
if ord == None or ord == 'fro': if ord == None or ord == 'fro':
...@@ -1266,7 +1266,6 @@ def norm(x,ord): ...@@ -1266,7 +1266,6 @@ def norm(x,ord):
raise ValueError(0) raise ValueError(0)
class lstsq(theano.Op): class lstsq(theano.Op):
def __eq__(self, other): def __eq__(self, other):
pass pass
...@@ -1292,4 +1291,3 @@ class lstsq(theano.Op): ...@@ -1292,4 +1291,3 @@ class lstsq(theano.Op):
outputs[1][0] = zz[1] outputs[1][0] = zz[1]
outputs[2][0] = zz[2] outputs[2][0] = zz[2]
outputs[3][0] = zz[3] outputs[3][0] = zz[3]
>>>>>>> Fixed swapaxes function in var, indentation error in test_basic and added lstsq function in ops with tests.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论