train_ds=train_ds.flat_map(lambdaw1,w2:tf.data.Dataset.zip((w1.batch(2),w2.batch(2))))# see https://stackoverflow.com/questions/55429307/how-to-use-windows-created-by-the-dataset-window-method-in-tensorflow-2-0
# generate the target label depending on whether the labels match or not
#NOTE: For cars196 & other datasets with many classes, the rejection resampling
# used to balance the positive and negative classes does NOT work anymore! (the input pipeline chokes)
# Need to find a better solution!
# -> FIX: Using class weights based on the number of labels in the original dataset seems to work perfectly well (and training speed improves greatly too)
# Load dataset in a form already consumable by Tensorflow
ds=tfds.load(DATASET_NAME,split='train')
# Resize images to the model's input size and normalize to [0.0, 1.0] as per the
train_ds=train_ds.flat_map(lambdaw1,w2:tf.data.Dataset.zip((w1.batch(2),w2.batch(2))))# see https://stackoverflow.com/questions/55429307/how-to-use-windows-created-by-the-dataset-window-method-in-tensorflow-2-0
# generate the target label depending on whether the labels match or not