提交 653c8484 authored 作者: Tanjay94's avatar Tanjay94

Removed unnecessary z variable in norm function.

上级 e7204ea2
...@@ -1229,17 +1229,13 @@ def norm(x,ord): ...@@ -1229,17 +1229,13 @@ def norm(x,ord):
raise ValueError("'axis' entry is out of bounds.") 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 return tensor.sum(x**2)**0.5
return z
elif ord == 'inf': elif ord == 'inf':
z = tensor.max(abs(x)) return tensor.max(abs(x))
return z
elif ord == '-inf': elif ord == '-inf':
z = tensor.min(abs(x)) return tensor.min(abs(x))
return z
elif ord == 0: elif ord == 0:
z = x[x.nonzero()].shape[0] return x[x.nonzero()].shape[0]
return z
else: else:
try: try:
z = tensor.sum(abs(x**ord))**(1./ord) z = tensor.sum(abs(x**ord))**(1./ord)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论