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

 using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using System.Xml.XPath; //<table class="common-table medium js-table js-stre...