-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Added the mode "bilinear" in the upscaling2D layer. #10994
Added the mode "bilinear" in the upscaling2D layer. #10994
Conversation
…sampling_bilinear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing, otherwise looks good
keras/backend/cntk_backend.py
Outdated
else: | ||
raise ValueError('CNTK Backend: Invalid data_format:', data_format) | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the existing behavior better here?
raise ValueError('CNTK Backend: Invalid data_format:', data_format)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have this message when giving as an input a wrong data_format. But it's true that the NotImplementedError is not clear at all. Let me change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
@@ -862,6 +862,45 @@ def test_upsampling_2d(): | |||
assert_allclose(np_output, expected_out) | |||
|
|||
|
|||
@pytest.mark.skipif((K.backend() == 'cntk'), | |||
reason="cntk does not support it yet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use '
for string delimitation, for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, my bad.
tests/keras/backend/backend_test.py
Outdated
@staticmethod | ||
def _helper_bilinear(height_factor, width_factor): | ||
x_shape = (2, 3, 4, 5) | ||
for data_format in ['channels_first', 'channels_last']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to make data_format
as argument of _helper_bilinear
. Then parameterize test_resize_images_bilinear
with data_format
. Otherwise, you may not be able to test both data_format
with pytest.raises
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I'll change that.
keras/backend/theano_backend.py
Outdated
@@ -19,6 +19,7 @@ | |||
except ImportError: | |||
from theano.sandbox.softsign import softsign as T_softsign | |||
|
|||
import warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Let me remove that.
It seems that |
@@ -862,6 +862,45 @@ def test_upsampling_2d(): | |||
assert_allclose(np_output, expected_out) | |||
|
|||
|
|||
@pytest.mark.skipif((K.backend() == 'cntk'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this test parameterized (see #10975)
* keras/master: (327 commits) Added in_train_phase and in_test_phase in the numpy backend. (keras-team#11061) Make sure the data_format argument defaults to ‘chanels_last’ for all 1D sequence layers. Speed up backend tests (keras-team#11051) Skipped some duplicated tests. (keras-team#11049) Used decorators and WITH_NP to avoid tests duplication. (keras-team#11050) Cached the theano compilation directory. (keras-team#11048) Removing duplicated backend tests. (keras-team#11037) [P, RELNOTES] Conv2DTranspose supports dilation (keras-team#11029) Doc Change: Change in shape for CIFAR Datasets (keras-team#11043) Fix line too long in mnist_acgan (keras-team#11040) Enable using last incomplete minibatch (keras-team#8344) Better UX (keras-team#11039) Update lstm text generation example (keras-team#11038) fix a bug, load_weights doesn't return anything (keras-team#11031) Speeding up the tests by reducing the number of K.eval(). (keras-team#11036) [P] Expose monitor value getter for easier subclass (keras-team#11002) [RELNOTES] Added the mode "bilinear" in the upscaling2D layer. (keras-team#10994) Separate pooling test from convolutional test and parameterize test case (keras-team#10975) Fix issue with non-canonical TF version name format. Allow TB callback to display float values. ...
cool! thanks for pushing this through @gabrieldemarmiesse! |
You're welcome! |
@gabrieldemarmiesse |
Hi thank you for the hard work! I have a question about the tensorflow implementation of resize_images. The current implementation in keras uses tf.image.resize_images, which suffers from a list of problems depending on the version:
In order not to break the previous code, would that make sense to add an option like 'nearest_by_tile', which uses the K.repeat_elements as in the CNTK back-end? Than you for your consideration and please correct me if I mis-understood things here |
Summary
Thanks @ahundt for your work. I was able to get Theano working and be compatible with what was doing tensorflow, but only for (2, 2) upscaling. Other factors like (4, 4) show different results for the theano's implementation and the tensorflow's implementation.
I also couldn't figure out how to use other factors like (3, 2) with theano. Which is why, with the Theano backend, for implementation and backend compatibility reasons, only (2, 2) is implemented.
Related Issues
See @ahundt 's PR: #9303
PR Overview