blocks
blocks copied to clipboard
Pooling classes can't return output dimension with unspecified image size
The Pooling
classes should be able to provide output dimensions when the image size is unspecified for use with ConvolutionalSequence
, but this currently raises an exception:
>>> from blocks.bricks.conv import MaxPooling
>>> m = MaxPooling((1, 1))
>>> m.get_dim('output')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/blocks/bricks/conv.py", line 289, in get_dim
ignore_border=self.ignore_border, padding=self.padding))
File "/usr/local/lib/python3.5/dist-packages/theano/tensor/signal/pool.py", line 189, in out_shape
r += padding[0] * 2
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'
This is a relatively simple fix---the Pooling.get_dim()
could just do a check---but it looks like it was written with the same idea as Convolutional
---that None
could be handled by just passing it down to Theano. Unfortunately it looks like the Pool.out_shape()
in Theano doesn't like that. I've opened this issue to see if others would prefer trying to rely on Theano to make the change---if just doing a check in Pooling.get_dim()
makes more sense, I'd be happy to submit a PR for it or include it in #1047.
It'd be nice if Theano supported that case but I think it's fine to special-case our code. Feel free to submit a PR.