GoogleCloudPlatform / practical-ml-vision-book

Apache License 2.0
485 stars 228 forks source link

Data augmentation layers generating multiple images #1

Closed FalsoMoralista closed 3 years ago

FalsoMoralista commented 3 years ago

@lakshmanok, i have recently read you article on writing a custom augmentation layer (this tutorial) and wondered if you have any ideas on how to handle augmentation layers that generates multiple images. I have implemented one model to do so but i don't know how to associate the original labels to the corresponding generated images which leads to mismatches between logits and labels when training the model.

Code in the link below: https://stackoverflow.com/questions/68136779/logits-and-labels-must-be-broadcastable-data-augmentation-layers-makes-logits-a

Any help and suggestions are welcome.

lakshmanok commented 3 years ago

Any Keras layer will have to keep the batch size the same as the input, so it's not possible as a Keras layer.

If you really want to generate multiple images, you would have to do this in the ingest pipeline.

That said, the more common approach is to randomly select one out of the multiple images during each epoch. If you do that, you can keep it as a layer within the model.

FalsoMoralista commented 3 years ago

I understand, thank you very much for your time.