提交 8e56ea6c authored 作者: Olivier Delalleau's avatar Olivier Delalleau

float('inf') does not work in Python 2.4.4 under Windows, using numpy.inf instead

上级 4c1ac5eb
......@@ -5,12 +5,13 @@ if sys.version_info[:2] >= (2,5):
else:
from python25 import defaultdict
import numpy
import opt
from theano.configparser import TheanoConfigParser, AddConfigVar, FloatParam
from theano import config
AddConfigVar('optdb.position_cutoff',
'Where to stop eariler during optimization. It represent the position of the optimizer where to stop.',
FloatParam(float('inf')),
FloatParam(numpy.inf),
in_c_key=False)
class DB(object):
......
......@@ -138,7 +138,7 @@ class multiple_outputs_numeric_grad:
if numpy.all(numpy.isfinite(errs)):
return numpy.max(errs), numpy.argmax(errs)
else:
return float('inf'), 0
return numpy.inf, 0
......
......@@ -1297,7 +1297,7 @@ class _tensor_py_operators:
def norm(self, L, axis=None):
if L==0:
raise NotImplementedError()
if L==float('inf'):
if numpy.isinf(L):
raise NotImplementedError()
#optimizations will/should catch cases like L=1, L=2
return pow(pow(abs_(self), L).sum(axis=axis), 1.0/L)
......
......@@ -133,7 +133,7 @@ class DownsampleFactorMax(Op):
zz=z[0]
## zz needs to be initialized with -inf for the following to work
zz -= float('inf')
zz -= numpy.inf
ds0, ds1 = self.ds
if self.ignore_border:
x_usable2 = (x.shape[2] / ds0 * ds0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论