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

Small fixes on image.extract_patches #647

Merged
merged 2 commits into from
Jul 31, 2023

Conversation

guillaumebaquiast
Copy link
Contributor

Two small fixes on extract_patches:

  • Passing argument size as an int currently fails for symbolic tensor:
>>> x = KerasTensor([None, 20, 20, 3])
>>> keras_core.ops.image.extract_patches(x, size=5)
Traceback (most recent call last):
...
    strides = (self.size[0], self.size[1])
TypeError: 'int' object is not subscriptable

Fixed and added unit-test.

  • Examples in docstring are failing for me, I have to convert the arrays to "float32" beforehand.
>>> image = np.random.random((1, 20, 20, 3)) # batch of 2 RGB images
>>> patches = keras_core.ops.image.extract_patches(image, (5, 5))
Traceback (most recent call last):
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: cannot compute Conv2D as input #1(zero-based) was expected to be a double tensor but is a float tensor [Op:Conv2D] name:

I edited the docstring accordingly.

Copy link
Contributor

@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.

LGTM, thanks for the fix!

@fchollet fchollet merged commit 6b4d054 into keras-team:main Jul 31, 2023
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.

2 participants