def mix_generator(X_train, Y_train, img_dir, batch_size, shuffle=True):
    alpha = 0.2
    gen1 = train_generator(X_train, Y_train, img_dir, batch_size, shuffle)
    gen2 = train_generator(X_train, Y_train, img_dir, batch_size, shuffle)
    while True:
        batch1 = next(gen1)
        batch2 = next(gen2)
        current_batch_size = batch1[0].shape[0]
        l = np.random.beta(alpha, alpha, current_batch_size)
        X_l = l.reshape(current_batch_size, 1, 1, 1)
        Y_l = l.reshape(current_batch_size, 1)
        batch_x = ((batch1[0] * X_l) + (batch2[0] * (1 - X_l)))
        batch_y = ((batch1[1] * Y_l) + (batch2[1] * (1 - Y_l)))
        (yield (batch_x, batch_y))
def mix_generator(X_train, Y_train, img_dir, batch_size, shuffle=True):
    alpha = 0.2
    gen1 = train_generator(X_train, Y_train, img_dir, batch_size, shuffle)
    gen2 = train_generator(X_train, Y_train, img_dir, batch_size, shuffle)
    while True:
        batch1 = next(gen1)
        batch2 = next(gen2)
        current_batch_size = batch1[0].shape[0]
        l = np.random.beta(alpha, alpha, current_batch_size)
        X_l = l.reshape(current_batch_size, 1, 1, 1)
        Y_l = l.reshape(current_batch_size, 1)
        batch_x = ((batch1[0] * X_l) + (batch2[0] * (1 - X_l)))
        batch_y = ((batch1[1] * Y_l) + (batch2[1] * (1 - Y_l)))
        (yield (batch_x, batch_y))