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 = (180, 180), 
    batch_size = 32, 
    class_mode = "sparse" 
)

No comments:

Post a Comment

Comparing features of LangGraph vs CrewAI

LangGraph Orchestration vs CrewAI Orchestration The following table compares LangGraph and CrewAI orchestration across their menta...