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.

Comment From: mehtamansi29

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.

Comment From: sonali-kumari1

Hi @grasskin - I have tested semisupervised_simclr.py in this gist with the latest version of keras(3.10.0) using layers.Rescaling(1 / 255) and it works fine. Notably, not specifying dtype="uint8" gives better augmented images. However, using dtype in rescaling layer gives black images, possibly due to casting to unit8.

Comment From: github-actions[bot]

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.