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

Catch scipy related complex warning

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