import math def get_compatible_batch_size(batch_size, neg_sample_size): if neg_sample_size < batch_size and batch_size % neg_sample_size != 0: old_batch_size = batch_size batch_size = int(math.ceil(batch_size / neg_sample_size) * neg_sample_size) print('batch size ({}) is incompatible to the negative sample size ({}). Change the batch size to {}'.format( old_batch_size, neg_sample_size, batch_size)) return batch_size