0

Apologies in advance. I am attempting to recreate this CNN (from the Keras Code Examples), with another dataset. https://keras.io/examples/vision/image_classification_from_scratch/

The dataset I am using is one for retinal scans, and classifies images on a scale from 0-4. So, it's a multi-label image classification.

The Keras example used is binary classification (cats v dogs), though I would have hoped it wouldn't make much difference (maybe this is a big assumption on my part).

I skipped the 'image augmentation' part of the walkthrough. So, I have not created the

data_augmentation = keras.Sequential(
    [
        layers.RandomFlip("horizontal"),
        layers.RandomRotation(0.1),
    ]
)

part. So, instead of:

def make_model(input_shape, num_classes):
    inputs = keras.Input(shape=input_shape)
    # Image augmentation block
    x = data_augmentation(inputs)

    # Entry block
    x = layers.Rescaling(1.0 / 255)(x)
.......

at the beginning of the model, I have:

def make_model(input_shape, num_classes):
    inputs = keras.Input(shape=input_shape)
    # Image augmentation block
    x = keras.Sequential(inputs)

    # Entry block
    x = layers.Rescaling(1.0 / 255)(x)
.......

However I keep getting different errors no matter how much I try to change things around, such as "TypeError: Keras symbolic inputs/outputs do not implement __len__.", or "ValueError: Exception encountered when calling layer "rescaling_3" (type Rescaling).". What am I missing here?

brosefzai
  • 49
  • 5
  • Why are you doing x = keras.Sequential(inputs)? This makes no sense. – Dr. Snoopy Aug 08 '22 at 19:09
  • Because the original code has `x = data_augmentation(inputs)`, where `data_augmentation = keras.Sequential( [ layers.RandomFlip("horizontal"), layers.RandomRotation(0.1), ] )`. I don't have a need to augment the data, so this becomes: `data_augmentation = keras.Sequential()`. And so if `data_augmentation` is simply calling on `keras.Sequential()`, hence `x = keras.Sequential(inputs)`... no? – brosefzai Aug 09 '22 at 12:59
  • No, if you do not need that, the identity operation would be x = inputs, not using Sequential. – Dr. Snoopy Aug 09 '22 at 15:33

0 Answers0