提交 ba551663 authored 作者: Nicolas Ballas's avatar Nicolas Ballas

Catch scipy related complex warning

上级 e563c53c
...@@ -10,6 +10,7 @@ from theano.gof import Apply, Op ...@@ -10,6 +10,7 @@ from theano.gof import Apply, Op
from six.moves import xrange from six.moves import xrange
import warnings
import numpy import numpy
try: try:
from scipy.signal.signaltools import _valfrommode, _bvalfromboundary from scipy.signal.signaltools import _valfrommode, _bvalfromboundary
...@@ -458,9 +459,13 @@ class BaseAbstractConv2d(Op): ...@@ -458,9 +459,13 @@ class BaseAbstractConv2d(Op):
out = numpy.zeros(out_shape, dtype=img.dtype) out = numpy.zeros(out_shape, dtype=img.dtype)
val = _valfrommode(mode) val = _valfrommode(mode)
bval = _bvalfromboundary('fill') bval = _bvalfromboundary('fill')
with warnings.catch_warnings():
warnings.simplefilter('ignore', numpy.ComplexWarning)
for b in xrange(img.shape[0]): for b in xrange(img.shape[0]):
for n in xrange(kern.shape[0]): for n in xrange(kern.shape[0]):
for im0 in xrange(img.shape[1]): for im0 in xrange(img.shape[1]):
# some cast generates a warning here
out[b, n, ...] += _convolve2d(img[b, im0, ...], out[b, n, ...] += _convolve2d(img[b, im0, ...],
kern[n, im0, ...], kern[n, im0, ...],
1, val, bval, 0) 1, val, bval, 0)
......
...@@ -794,10 +794,13 @@ class ConvOp(OpenMPOp): ...@@ -794,10 +794,13 @@ class ConvOp(OpenMPOp):
val = _valfrommode(self.out_mode) val = _valfrommode(self.out_mode)
bval = _bvalfromboundary('fill') bval = _bvalfromboundary('fill')
with warnings.catch_warnings():
warnings.simplefilter('ignore', numpy.ComplexWarning)
for b in xrange(bsize): for b in xrange(bsize):
for n in xrange(nkern): for n in xrange(nkern):
zz[b, n, ...].fill(0) zz[b, n, ...].fill(0)
for im0 in xrange(stacklen): for im0 in xrange(stacklen):
# some cast generates a warning here
zz[b, n, ...] += _convolve2d(img2d[b, im0, ...], zz[b, n, ...] += _convolve2d(img2d[b, im0, ...],
filtersflipped[n, im0, ...], filtersflipped[n, im0, ...],
1, val, bval, 0) 1, val, bval, 0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论