Skip to content

Conversation

@joelthchao
Copy link
Contributor

@joelthchao joelthchao commented Aug 24, 2018

Summary

Split convolutional layers tests and pooling tests (currently both are in convolutional_test.py); make convolutional_test.py tests use parameterized tests instead of inner for loops for different cases.

Related Issues

PR Overview

  • This PR requires new unit tests [y/n] (make sure tests are included)
  • This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
  • This PR is backwards compatible [y/n]
  • This PR changes the current API [y/n] (all API changes need to be approved by fchollet)

@joelthchao
Copy link
Contributor Author

PEP8 fails due to W503. I think we should ignore it (ref).

@joelthchao joelthchao mentioned this pull request Aug 24, 2018
4 tasks
@joelthchao joelthchao force-pushed the improve-convolutional-test branch 2 times, most recently from 747265f to 86a1efe Compare August 25, 2018 07:40
@joelthchao joelthchao closed this Aug 28, 2018
@joelthchao joelthchao reopened this Aug 28, 2018
Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

]
)
def test_causal_dilated_conv(
input_length, kernel_size, dilation_rate, padding, expected_output):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this parameterization pattern is not ideal for readability. It is not easy to assess at a glance what the tests cases are, and it is not easy to add new ones.

I suggest the following pattern for better readability:

@pytest.mark.parametrize('layer_kwargs,input_length,output_length',
   [({'filters': 3, ...}, 5, 3),
     ...])
def test_causal_dilated_conv(layer_kwargs, input_shape, output_shape):
    input_data = ...
    expected_output = ...
    layer_test(convolutional.Conv1D, input_data=input_data, kwargs=layer_kwargs, expected_output=expected_output)

That way the different layer configurations are enumerated as dictionaries: you immediately know the value of each named argument.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, indeed. You approach is more readable. I will fix it later.

@joelthchao joelthchao force-pushed the improve-convolutional-test branch from 6074223 to 4dab8ba Compare August 29, 2018 15:07
@fchollet fchollet merged commit 4c01596 into keras-team:master Aug 29, 2018
jlherren added a commit to jlherren/keras that referenced this pull request Sep 3, 2018
* 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.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants