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

Rescaling layer defaults to "float32" if dtype not specified - input is uint8 #18464

Open
grasskin opened this issue Jun 5, 2023 · 1 comment
Assignees
Labels

Comments

@grasskin
Copy link
Member

grasskin commented Jun 5, 2023

Backwards incompatibility from semisupervised_simclr.py

Input image is tf.Tensor(shape=(8, 96, 96, 3), dtype=uint8) and is unable to multiply by float tensor in rescaling layer.

Current workaround is to add dtype via layers.Rescaling(1 / 255, dtype="uint8") in line 217.

I assume keras used to detect that input was uint8 which is why dtype was not specified.

@fchollet fchollet transferred this issue from keras-team/keras-core Sep 22, 2023
@mehtamansi29
Copy link
Collaborator

Hi @grasskin -

I am able to reproduce the issue when dtype=uint8 in layers.Rescaling(1 / 255, dtype="uint8").
Error Traceback:

ValueError                                Traceback (most recent call last)
[<ipython-input-21-4470e15678cc>](https://localhost:8080/#) in <cell line: 2>()
      1 # Baseline supervised training with random initialization
----> 2 baseline_model = keras.Sequential(
      3     [
      4         get_augmenter(**classification_augmentation),
      5         get_encoder(),

2 frames
[/usr/local/lib/python3.10/dist-packages/keras/src/models/sequential.py](https://localhost:8080/#) in input_shape(self)
    269         if self._functional:
    270             return self._functional.input_shape
--> 271         raise ValueError(
    272             f"Sequential model '{self.name}' has no defined input shape yet."
    273         )

ValueError: Sequential model 'sequential_24' has no defined input shape yet.

Also while visualizing image using dtype=uint8 then augmented images are not properly visualize.
Attached gist for the reference. We look into the issue more and update.

@mehtamansi29 mehtamansi29 added the keras-team-review-pending Pending review by a Keras team member. label Sep 13, 2024
@mehtamansi29 mehtamansi29 self-assigned this Sep 13, 2024
@SamanehSaadat SamanehSaadat self-assigned this Sep 19, 2024
@SamanehSaadat SamanehSaadat removed the keras-team-review-pending Pending review by a Keras team member. label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants