Wednesday, May 12, 2021

 InvalidArgumentError: logits and labels must have the same first dimension, got logits shape [32,5] and labels shape [160]



This happens when the class_mode of ImageDataGenerator is not in sync with num of classes in the dataset.

Suppose you are working on 5 to 10 classes, you should ideally specify class_mode = "sparse"

If you don't, the above error is flashed.


train_ds_gen = flowers_gen.flow_from_directory(
    "/content/flowers/flower_photos"
    subset = "training"
    seed = 123,
    target_size = (180180), 
    batch_size = 32
    class_mode = "sparse" 
)

No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...