Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to infer the output shape for Deconvolution2D layer #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion keras/backend/theano_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,15 @@ def deconv2d(x, kernel, output_shape, strides=(1, 1),
np_kernel = kernel.eval()
filter_shape = _preprocess_filter_shape(dim_ordering, shape(kernel))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was a kind of inconsistency here - we receive the filter_shape as a parameter, after that we reshape the kernel itself (shape should change) but leave filter_shape intact and pass it to the AbstractConv2d_gradInputs then.

Probably we could totally remove filter_shape from the parameters, if there are no other reasons to use it.


_t = ()
for v in output_shape:
try:
v = v.eval()
_v = v.eval()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I stuck probably the same issue that @yaringal mentioned - if we infer output_shape, it becomes the tuple of Theano variables/expressions, which Theano couldn't accept as an input due to some reasons.
So I try to evaluate them, but here I get another error:

MissingInputError: An input of the graph, used to compute Shape(input_25), was not provided and not given a value.Use the Theano flag exception_verbosity='high',for more information on this error.

I'm not an expert in Theano, so have no idea how to fix it quick.

except AttributeError as e:
_v = v
print(e.__str__())
_t = _t + (v, )
output_shape = _t

print("imshp {} kshp {} subsample {} border_mode {} output_shape {}".format(output_shape, filter_shape, strides, th_border_mode, output_shape[2:]))

Expand Down